No Module Named '_pywrap_tensorflow_internal'

Question:

While trying to validate the installation of tensorflow-gpu, I get an ImportError when trying to execute “import tensorflow as tf”. I am using a Quadro K620 on Windows 7. Tensorflow was installed using pip.

The following is the stack trace:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:Usersaagarwal>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libsite-packag
estensorflowpythonpywrap_tensorflow_internal.py", line 18, in swig_import_hel
per
    return importlib.import_module(mname)
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libimportlib_
_init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 906, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libsite-packag
estensorflowpythonpywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libsite-packag
estensorflowpythonpywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libsite-packag
estensorflowpythonpywrap_tensorflow_internal.py", line 20, in swig_import_hel
per
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libimportlib_
_init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libsite-packag
estensorflow__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libsite-packag
estensorflowpython__init__.py", line 51, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libsite-packag
estensorflowpythonpywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libsite-packag
estensorflowpythonpywrap_tensorflow_internal.py", line 18, in swig_import_hel
per
    return importlib.import_module(mname)
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libimportlib_
_init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 906, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libsite-packag
estensorflowpythonpywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libsite-packag
estensorflowpythonpywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libsite-packag
estensorflowpythonpywrap_tensorflow_internal.py", line 20, in swig_import_hel
per
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:UsersaagarwalAppDataLocalProgramsPythonPython35libimportlib_
_init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
>>>

I have looked at multiple other stack overflow posts which things like correcting the path but I have not been able to solve this issue.

Asked By: Amit Agarwal

||

Answers:

After you install the CUDA Drivers you must download cuDNN and release it. After that you get to copy the cudnn64_5.dll to PATH.
If that doesn’t work, move the cudnn64_5.dll to
NVIDIA GPU Computing ToolkitCUDAv8.0bin and try it again. Otherwise you’d meet some error that you see.

Answered By: WHCer

https://github.com/tensorflow/tensorflow/issues/7705

switch to cuDNN 5.1 instead of 6.0

Answered By: mickdelaney

I came across the same issue today, please switch to cuDNN v5.1 Library for Windows instead as @mickdelaney suggested and then try to

  1. Check environment settings of CUDA, normally all the settings of CUDA had been added to Windows environment

  2. Copy files in bin, lib and include of cuDNN to bin, lib and include of CUDA respectively. Normally the directory is C:Program FilesNVIDIA GPU Computing ToolkitCUDA

And then you can import tensorflow and run your code. Good luck!

Answered By: GoingMyWay

I still got this error after installing cuDNN 5.1 (yes, I had PATH set correctly). I had better luck installing tensorflow_gpu from this site. This requires cuDNN 6.0, not 5.1. Unfortunately they currently only have Tensorflow 1.1 for GPU systems.

Answered By: aldel

I am a chinese, so my english is poor, and my answer is that however you use cudnn 7 or 6 or 5 , you must rename the dll from cudnn64_x.dll to cudnn64_6.dll after you copy files.
maybe soon, you need to rename the dll to 7 or 8 or 9 as possible.

Answered By: Paul

you could uninstall the current version of tensorflow and try a low version such as TensorFlow 0.12 using the code

pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl

https://blog.csdn.net/baidu_36669549/article/details/79734590

Answered By: Mars Marcin

I had the same error with anaconda, it was previously installed with another program through anaconda. Installing again through conda-forge worked: conda install -c conda-forge tensorflow

Answered By: cemsazara

this is all about your video chip/card and CPU compatibility with TF VERSION! Current version of Tensor Flow is 1.8 and it crashes on both my machines.

I have a win7 Gateway notebook using an I5 CPU and intel video chip. I have a desktop win7 unit with AMD Phenom II and AMD Radeon HD5450 video card. The I5 notebook requires V1.6 of TensorFlow and the desktop AMD unit takes V1.5. I don’t have a GPU available for running ANN’s so I don’t know how that would affect it.

Here’s the command line for PIP install: pip install –upgrade tensorflow==1.5.0 (or whatever other version you need). This will uninstall your current version and then install the indicated version.

Build or copy a small TensorFlow script and run it in a command window. Open a second command window and install a different version. I’d recommend starting at 1.5 and working your way up.

Answered By: stpaulchuck

I found the solution for the CPU: It worked for me

Just run below command if necessary then update it

pip install tensorflow==1.5

Answered By: EKNATH KULKARNI

The only thing that worked for me (Windows 10) is:
Install Microsoft Visual C++ 2015 Redistributable Update 3
If you have a new fresh computer setup this one might miss.

Answered By: maniac

It worked for me after doing this command :

pip install tensorflow-gpu == 1.15.5 

I was previously with tensorflow-gpu 1.15.0 when it was showing the error

Answered By: Myriam ESSAFOUI
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.