New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error importing tensorflow on windows 10 ( Tensorflow 0.12.0 RC0, python3.5 ) #5949

Closed
akrai48 opened this Issue Nov 29, 2016 · 41 comments

Comments

Projects
None yet
@akrai48
Copy link

akrai48 commented Nov 29, 2016

Was excited to try out 0.12.0 RC0 for windows
Followed Tensorflow 0.12.0 RC0 Installation guide for Windows, on Windows 10.
Ran into following error.

Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.

import tensorflow
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 906, in create_module
File "", 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:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python_init_.py", line 54, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow')
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<pyshell#0>", line 1, in
import tensorflow
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow_init_.py", line 24, in
from tensorflow.python import *
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python_init_.py", line 60, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 906, in create_module
File "", 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:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python_init_.py", line 54, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow')
File "C:\Users\hp\AppData\Local\Programs\Python\Python35\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow'

Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.

@mrry mrry self-assigned this Nov 29, 2016

@mrry

This comment has been minimized.

Copy link
Contributor

mrry commented Nov 29, 2016

I'm sorry that it didn't work out of the box. Can you answer a couple of questions for me?

  1. How did you install TensorFlow? Did you use pip install tensorflow or pip install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl (or some other command)?

  2. Can you run the following command and reply with its complete output?

dir C:\Users\hp\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\_pywrap_tensorflow.pyd
@akrai48

This comment has been minimized.

Copy link
Author

akrai48 commented Nov 29, 2016

  1. I used pip install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl as mentioned at https://www.tensorflow.org/versions/r0.12/get_started/os_setup.html#pip-installation-on-windows

  2. Here's the complete output:

Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.

C:\Users\hp>dir C:\Users\hp\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\_pywrap_tensorflow.pyd
 Volume in drive C is Windows
 Volume Serial Number is 903A-70A1

 Directory of C:\Users\hp\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python

11/30/2016  01:21 AM        31,525,376 _pywrap_tensorflow.pyd
               1 File(s)     31,525,376 bytes
               0 Dir(s)  96,176,766,976 bytes free

I'd would like to add that I have both version of python 2.7, 3.5 installed. I hope that's not the issue.

@mrry

This comment has been minimized.

Copy link
Contributor

mrry commented Nov 29, 2016

It sounds like it has installed correctly, but one of the dependencies is missing. According to dumpbin, the extension has the following dependencies:

  • KERNEL32.dll
  • WSOCK32.dll
  • WS2_32.dll
  • SHLWAPI.dll
  • python35.dll
  • MSVCP140.dll
  • VCRUNTIME140.dll
  • api-ms-win-crt-runtime-l1-1-0.dll
  • api-ms-win-crt-heap-l1-1-0.dll
  • api-ms-win-crt-utility-l1-1-0.dll
  • api-ms-win-crt-stdio-l1-1-0.dll
  • api-ms-win-crt-string-l1-1-0.dll
  • api-ms-win-crt-math-l1-1-0.dll
  • api-ms-win-crt-convert-l1-1-0.dll
  • api-ms-win-crt-environment-l1-1-0.dll
  • api-ms-win-crt-filesystem-l1-1-0.dll
  • api-ms-win-crt-time-l1-1-0.dll

Can you check that all of these files are on your system? It's possible that our development and test environment gets one of these from the build tools, and they aren't available as standard.

@mrry

This comment has been minimized.

Copy link
Contributor

mrry commented Nov 29, 2016

We've just been able to reproduce the same error, and it was caused by a missing MSVCP140.dll. (Thanks @wolffg!) Installing the Microsoft Visual C++ 2015 Redistributable Update 3 (x64 version) should fix it. Can you please try that and let us know if it works?

@akrai48

This comment has been minimized.

Copy link
Author

akrai48 commented Nov 30, 2016

@mrry , worked like a charm. Thank you very much for the effort.

@nvdanh81

This comment has been minimized.

Copy link

nvdanh81 commented Feb 18, 2017

@mrry 👍 Thanks very much!

@Mozitao

This comment has been minimized.

Copy link

Mozitao commented Feb 20, 2017

Thanks~~

@cloud-370

This comment has been minimized.

Copy link

cloud-370 commented Mar 17, 2017

@mrry , thank you.
your advise(installing Microsoft Visual C++ 2015 Redistributable Update 3 (x64 version) ) also work for native pip3 install tensorflow 1.0.1 on windows10.

@SonHoJae

This comment has been minimized.

Copy link

SonHoJae commented Mar 24, 2017

Thanks alot

@chichur

This comment has been minimized.

Copy link

chichur commented Mar 30, 2017

Thanks bro

@Randolph-zeng

This comment has been minimized.

Copy link

Randolph-zeng commented Apr 30, 2017

@mrry Sorry to bring this up again, I have the same issue as poster. I have been debugging this for several days but no luck. Any advice will be greatly appreciated!

I did lack all of the api-ms-win-crt-*.dll files and python35.dll specifically(I am running in a virtual env of python3.5 in anaconda). I downloaded all the dll files online and add it back to C:\Windows\SysWOW64 but the problem still persists.

I am using Python 3.5.3 |Continuum Analytics, Inc.| (default, Feb 22 2017, 21:28:42) [MSC v.1900 64 bit (AMD64)] on win32.

My Cuda version is 8.0 and the driver is in v6.0, I have added the cuDNN files to my PATH, which is C:\Users\rando\cudnn-8.0-windows10-x64-v6.0\cuda

My gpu is gtx-1080 and below is the error message:

import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 914, in create_module
File "", 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:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\importlib_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 "", line 1, in
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow_init_.py", line 24, in
from tensorflow.python import *
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python_init_.py", line 51, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 914, in create_module
File "", 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:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Users\rando\Anaconda3\envs\tensorflow-gpu\lib\importlib_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_problems

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

@Randolph-zeng

This comment has been minimized.

Copy link

Randolph-zeng commented Apr 30, 2017

@Carmezim Plz help, any advice will be greatly appreciated! Thanks a lot!

@YuriWerewolf

This comment has been minimized.

Copy link

YuriWerewolf commented Apr 30, 2017

Same issue here, TensorFlow works with CPU but not with GPU (Nvidia) on Windows 10

@YuriWerewolf

This comment has been minimized.

Copy link

YuriWerewolf commented Apr 30, 2017

You need to use cuDNN v.5.1, not version 6.0. Everything works for me after i have replaced v6.0 with v 5.1

@Carmezim

This comment has been minimized.

Copy link
Contributor

Carmezim commented Apr 30, 2017

@Randolph-zeng you shouldn't use cuDNN 6.0, according to TensorFlow requirements only 5.1 is supported on Windows.
For more information please see:
https://www.tensorflow.org/install/install_windows#requirements_to_run_tensorflow_with_gpu_support

@Randolph-zeng

This comment has been minimized.

Copy link

Randolph-zeng commented May 1, 2017

@Carmezim @YuriWerewolf Hi thanks for the answer, but I still can't get it to work.
I have the tensorflow cpu version working and I am pretty sure this is a problem of cuda now.
I have Cuda toolkit v8.0 and cuDNN v5.1 in my computer and I believe the path is correct.
Is there any other things I can look into? Thanks a million!
My path variable looks like this(with cuda related being the first several lines):

C:\Users\rando>path
PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;
C:\Users\rando\cudnn-8.0-windows10-x64-v5.1\cuda;
;C:\RBuildTools\3.4\bin;
C:\RBuildTools\3.4\mingw_64\bin;
D:\Rtools\bin;D:\Rtools\mingw_64\bin;
C:\Program Files (x86)\Intel\iCLS Client;
C:\Program Files\Intel\iCLS Client;
C:\Windows\system32;
C:\Windows;C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0;
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;
C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
C:\Users\rando.dnx\bin;
C:\Program Files\Microsoft DNX\Dnvm;
C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit;
C:\Program Files\Microsoft SQL Server\120\Tools\Binn;
C:\Program Files\Microsoft SQL Server\130\Tools\Binn;
C:\Program Files\Git\cmd;C:\Program Files\CMake\bin;C:\Program Files (x86)\GtkSharp\2.12\bin;
C:\Users\rando\cuda;
C:\Users\rando\Anaconda3;
C:\Users\rando\Anaconda3\Scripts;
C:\Users\rando\Anaconda3\Library\bin;
C:\Users\rando\AppData\Local\Programs\Python\Python35-32\Scripts;
C:\Users\rando\AppData\Local\Programs\Python\Python35-32;
C:\Users\rando\AppData\Local\Microsoft\WindowsApps;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0

@Carmezim

This comment has been minimized.

Copy link
Contributor

Carmezim commented May 1, 2017

@Randolph-zeng I cannot really tell only by looking at your %PATH%. If you're sure cuDNN DLLs are properly set as CUDA's it's not CUDA/cuDNN related.
Is your TensorFlow 1.1? You don't need both installations as well, CPU and GPU, I get it if you were just testing though. Maybe it would be better if you opened a new issue filling the template to better assess what can be happening. This problem usually yields from misconfigured CUDA/cuDNN as you said CPU works. TensorFlow team is working on improving this error message #9170.
You can notice by looking on this issue that is likely to be a missing CUDA/cuDNN DLL from your %PATH%.

@Randolph-zeng

This comment has been minimized.

Copy link

Randolph-zeng commented May 1, 2017

@Carmezim Okay, I will open a new issue. Thanks for the help! Have a great night!

@ianuzzi

This comment has been minimized.

Copy link

ianuzzi commented May 1, 2017

I'm having a similar problem. I tried rolling back to C++ Redist. 2015 (from 2017) and still not working.

`Traceback (most recent call last):
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Python35\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 914, in create_module
File "", 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:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Python35\lib\importlib_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 "", line 1, in
File "C:\Python35\lib\site-packages\tensorflow_init_.py", line 24, in
from tensorflow.python import *
File "C:\Python35\lib\site-packages\tensorflow\python_init_.py", line 51, in
from tensorflow.python import pywrap_tensorflow
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Python35\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 914, in create_module
File "", 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:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Python35\lib\importlib_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_problems

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

@GitHubKay

This comment has been minimized.

Copy link

GitHubKay commented May 17, 2017

I'm not sure if someone will look in here cause it's "closed". Anyway, i've the same issue. I installed TensorFlow-GPU:
1.) install anaconda 3.6
2.) conda install python==3.5
3.) pip install tensorflow-gpu
4.) Install CUDA 8.0
5.) Install cuDNN

I checked the import tensorflow as tf in my Jupiter Notebook and it worked.
The next day i did the same to follow first instructions with tensorflow
(Btw, i'm new to python, if someone has a good overview over all the packages and extensions as well as good tutorials... i'm more than pleased to here from you).
Anyway, i got the same error that @ianuzzi has. I followed the instructions above but without any change.

Thx for you help guys
Kay

@GitHubKay

This comment has been minimized.

Copy link

GitHubKay commented May 17, 2017


ImportError Traceback (most recent call last)
C:\Users\RazZzoR\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
17 try:
---> 18 return importlib.import_module(mname)
19 except ImportError:

C:\Users\RazZzoR\Anaconda3\lib\importlib_init_.py in import_module(name, package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
127

C:\Users\RazZzoR\Anaconda3\lib\importlib_bootstrap.py in _gcd_import(name, package, level)

C:\Users\RazZzoR\Anaconda3\lib\importlib_bootstrap.py in find_and_load(name, import)

C:\Users\RazZzoR\Anaconda3\lib\importlib_bootstrap.py in find_and_load_unlocked(name, import)

C:\Users\RazZzoR\Anaconda3\lib\importlib_bootstrap.py in _load_unlocked(spec)

C:\Users\RazZzoR\Anaconda3\lib\importlib_bootstrap.py in module_from_spec(spec)

C:\Users\RazZzoR\Anaconda3\lib\importlib_bootstrap_external.py in create_module(self, spec)

C:\Users\RazZzoR\Anaconda3\lib\importlib_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
C:\Users\RazZzoR\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in ()
40 sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL)
---> 41 from tensorflow.python.pywrap_tensorflow_internal import *
42 from tensorflow.python.pywrap_tensorflow_internal import version

C:\Users\RazZzoR\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in ()
20 return importlib.import_module('_pywrap_tensorflow_internal')
---> 21 _pywrap_tensorflow_internal = swig_import_helper()
22 del swig_import_helper

C:\Users\RazZzoR\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
19 except ImportError:
---> 20 return importlib.import_module('_pywrap_tensorflow_internal')
21 _pywrap_tensorflow_internal = swig_import_helper()

C:\Users\RazZzoR\Anaconda3\lib\importlib_init_.py in import_module(name, package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
127

ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
in ()
----> 1 import tensorflow as tf
2

C:\Users\RazZzoR\Anaconda3\lib\site-packages\tensorflow_init_.py in ()
22
23 # pylint: disable=wildcard-import
---> 24 from tensorflow.python import *
25 # pylint: enable=wildcard-import
26

C:\Users\RazZzoR\Anaconda3\lib\site-packages\tensorflow\python_init_.py in ()
49 import numpy as np
50
---> 51 from tensorflow.python import pywrap_tensorflow
52
53 # Protocol buffers

C:\Users\RazZzoR\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in ()
50 for some common reasons and solutions. Include the entire stack trace
51 above this error message when asking for help.""" % traceback.format_exc()
---> 52 raise ImportError(msg)
53
54 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback (most recent call last):
File "C:\Users\RazZzoR\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\RazZzoR\Anaconda3\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 903, in create_module
File "", line 222, in _call_with_frames_removed
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\RazZzoR\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\RazZzoR\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\RazZzoR\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Users\RazZzoR\Anaconda3\lib\importlib_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_problems

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

@mrry

This comment has been minimized.

Copy link
Contributor

mrry commented May 31, 2017

For users who find this issue when searching for the error message, I've created a script for diagnosing common TensorFlow on Windows installation issues. Please download the script from https://gist.github.com/mrry/ee5dbcfdd045fa48a27d56664411d41c and run python tensorflow_self_check.py. It will print suggestions for how to fix your installation. Let me know if you are still facing problems after running the script.

@dakshj

This comment has been minimized.

Copy link

dakshj commented Jun 1, 2017

@mrry Thanks for your script! Worked for me.
My issue was that the PATH for cuDNN was set to D:\TensorFlow\cudnn-8.0-windows10-x64-v5.1\cuda, but the correct PATH for it was D:\TensorFlow\cudnn-8.0-windows10-x64-v5.1\cuda\bin.

@alphashuro

This comment has been minimized.

Copy link

alphashuro commented Jun 3, 2017

@mrry thank you your script is very helpful, why don't you submit a pull request to add this script to the tensorflow library itself, so that it can be used as an install step?

@mrry

This comment has been minimized.

Copy link
Contributor

mrry commented Jun 3, 2017

@alphashuro I'm glad it helped! Eventually we'll want to integrate some of the heuristics in the script into the import process, but I wanted to get something out there ASAP to help people who were struggling with these problems :). (One slight issue with integrating it in the repository is that we'd like it to be usable for people who haven't managed to install the library correctly....)

@BattleCisco

This comment has been minimized.

Copy link

BattleCisco commented Jun 11, 2017

@YuriWerewolf @Carmezim Thank you, I installed 6.0 and wondered why it didn't work, uninstalling 6.0 and installing 5.1 worked for me.

Thanks for the help, stay awesome 👍

@zhenglilei

This comment has been minimized.

Copy link

zhenglilei commented Jul 18, 2017

@YuriWerewolf @Carmezim Thank you, I installed 6.0 and wondered why it didn't work, uninstalling 6.0 and installing 5.1 worked for me.

@XRarach

This comment has been minimized.

Copy link

XRarach commented Aug 6, 2017

This is maybe a very stupid mistake but might help someone... I downloaded just CUDA 8 patch from the site and was wondering, why the error. Apparently, the patch does not care if you have CUDA 8 already installed, it just copied the dll and creates the intermediary directories, even looks like Cuda is installed in installed applications.

@prdas31

This comment has been minimized.

Copy link

prdas31 commented Aug 18, 2017

Okay. Solved it. Same issue as TensorFlow 1.3 or later requires cuDNN 6. ('cudnn64_6.dll')

@hisham-hy1508805

This comment has been minimized.

Copy link

hisham-hy1508805 commented Aug 22, 2017

@prdas31 Thank you ... I solved my issue.
I have TensorFlow 1.3, upgrading to cuDNN 6 instead of v5.1 solved the issue
@mrry your script is awesome ... was very helpful for me

@aenciso

This comment has been minimized.

Copy link

aenciso commented Sep 6, 2017

@mrry best script ever! Thanks. I spent hours debugging, reinstalling, etc. You have save my day. Thanks a lot.

@carlhuth

This comment has been minimized.

Copy link

carlhuth commented Oct 23, 2017

I wanted to bring up an anomaly that occurred with pip that was causing the No module named '_pywrap_tensorflow_internal' error to occur. The version of python I was running was Python 3.6.3, pip was version 9.0.1. and it was running on Windows 10.

**Using version 1.3.0 (newest of versions: 1.2.0, 1.2.1, 1.3.0) Looking up "https://pypi.python.org/packages/bf/d4/80197f48f9fb90a17c47cdd834b2f13d5f714f26e8ed5c77069d57aa3ecb/tensorflow-1.3.0-cp36-cp36m-win_amd64.whl" in the cache** Current age based on date: 67543 Freshness lifetime from max-age: 31557600 The response is "fresh", returning cached response 31557600 > 67543 _Using cached tensorflow-1.3.0-cp36-cp36m-win_amd64.whl_ Downloading from URL https://pypi.python.org/packages/bf/d4/80197f48f9fb90a17c47cdd834b2f13d5f714f26e8ed5c77069d57aa3ecb/tensorflow-1.3.0-cp36-cp36m-win_amd64.whl#md5=3a7dbe9a17d806e43d2e71b3ddb0cd52 (from https://pypi.python.org/simple/tensorflow/)

The installation command was pip3 install --upgrade tensorflow, which on first run appeared to be working perfectly fine, however that was not the truth. I discovered 3 weird occurrences:

  1. The site-package that was downloaded had a METADATA stating it was for Python 2.7. (This obviously was not going to work if it was for the wrong version of Python.) Also, the TensorFlow version was 1.3 instead of the most current 1.4.0rc0 that was expected (verified this by going directly to pypi.python.org site directly).

  2. Upon uninstalling the package, I noticed it had saved a cached instance of the package under my user profile as well, which it did not remove when uninstalling the package. That was found in C:\Users**{AccountName}**\AppData\Local\Tmp\Pip-{unique generated id for cached application} and also removed.

  3. After removing the cached modules, I again ran the command but with the verbose argument set: pip3 install --upgrade -v tensorflow
    This was assumed to be something that would download the correct version of tensorflow now, but instead it decided that it couldn't find a compatible version of TensorFlow for my Python version 3.6.3 (which I assume the minor rev number may have thrown off the basic logic for acceptable versions, ex. 3.5, 3.6). I again looked at the package metadata for the server-side cached copy of the module and again saw that this was really limited to Python 2.7 again. Which means the server was returning an invalid python package that python 3 could not run, all while saying it was it was the newest version available, which was definitely not true.

The solution was quite simple, I added a forced version number to match the most current version's name, which ran seamlessly and resolved the import error described above.

pip3 install --upgrade -v tensorflow==1.4.0rc0

@sytelus

This comment has been minimized.

Copy link

sytelus commented Dec 23, 2017

I have seen this error occuring in Tensorflow 1.4.0 as well because either cuDNN or CUDA toolkit DLLs being of wrong version or found in Anaconda folder instead of NVidia's folder. I've written a blog post on how to debug this error:

http://shitalshah.com/p/debugging-tensorflow-dll-importerror/

Related issue: #14946

@rohanpatkar

This comment has been minimized.

Copy link

rohanpatkar commented Jan 3, 2018

@mrry I wasted ample time before coming to this page. I was trying cpu installation of TF. It got resolved after installing visual c++. Thanks much for help.

@xenonkfr

This comment has been minimized.

Copy link

xenonkfr commented Feb 11, 2018

i tried the selfcheck.py and the report is as follows:

ERROR: Failed to import the TensorFlow module.

  • Python version is 3.6.

  • TensorFlow is installed at: C:\Users......\Anaconda3\lib\site-packages\tensorflow

  • Could not load 'cudart64_80.dll'. The GPU version of TensorFlow
    requires that this DLL be installed in a directory that is named in
    your %PATH% environment variable. Download and install CUDA 8.0 from
    this URL: https://developer.nvidia.com/cuda-toolkit

  • Could not load 'cudnn64_5.dll'. The GPU version of TensorFlow
    requires that this DLL be installed in a directory that is named in
    your %PATH% environment variable. Note that installing cuDNN is a
    separate step from installing CUDA, and it is often found in a
    different directory from the CUDA DLLs. You may install the
    necessary DLL by downloading cuDNN 5.1 from this URL:
    https://developer.nvidia.com/cudnn

  • Could not find cuDNN 5.1.

@Shakxzz

This comment has been minimized.

Copy link

Shakxzz commented Mar 11, 2018

I am stuck since hours but the issue is still not resolved.
I am using only the CPU version and getting the same No module named 'pywrap_tensorflow_internal' error ::
Traceback (most recent call last):
File "C:\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Python\Python36\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 658, in _load_unlocked
File "", line 571, in module_from_spec
File "", line 922, in create_module
File "", line 219, in _call_with_frames_removed
ImportError: DLL load failed with error code -1073741795

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Python\Python36\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<pyshell#0>", line 1, in
import tensorflow
File "C:\Python\Python36\lib\site-packages\tensorflow_init_.py", line 24, in
from tensorflow.python import *
File "C:\Python\Python36\lib\site-packages\tensorflow\python_init_.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "C:\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Python\Python36\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 994, in _gcd_import
File "", line 971, in _find_and_load
File "", line 955, in _find_and_load_unlocked
File "", line 658, in _load_unlocked
File "", line 571, in module_from_spec
File "", line 922, in create_module
File "", line 219, in _call_with_frames_removed
ImportError: DLL load failed with error code -1073741795

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "C:\Python\Python36\lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

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

**1. I have placed msvcp140.dll in system32(64-bit file) and SysWOW64(32-bit file) as advised in https://www.youtube.com/watch?v=61vwFxnnh5c

  1. I have also downloaded and installed Microsoft Visual C++ 2015 Redistributable Update 3

  2. On running the selfcheck.py, I am getting the following result::**
    ERROR: Failed to import the TensorFlow module.

WARNING! This script is no longer maintained!

Since TensorFlow 1.4, the self-check has been integrated with TensorFlow itself,
and any missing DLLs will be reported when you execute the import tensorflow
statement. The error messages printed below refer to TensorFlow 1.3 and earlier,
and are inaccurate for later versions of TensorFlow.

  • Python version is 3.6.

  • TensorFlow is installed at: C:\Python\Python36\lib\site-packages\tensorflow

  • Could not load 'cudart64_80.dll'. The GPU version of TensorFlow
    requires that this DLL be installed in a directory that is named in
    your %PATH% environment variable. Download and install CUDA 8.0 from
    this URL: https://developer.nvidia.com/cuda-toolkit

  • Could not load 'nvcuda.dll'. The GPU version of TensorFlow requires that
    this DLL be installed in a directory that is named in your %PATH%
    environment variable. Typically it is installed in 'C:\Windows\System32'.
    If it is not present, ensure that you have a CUDA-capable GPU with the
    correct driver installed.

  • Could not load 'cudnn64_5.dll'. The GPU version of TensorFlow
    requires that this DLL be installed in a directory that is named in
    your %PATH% environment variable. Note that installing cuDNN is a
    separate step from installing CUDA, and it is often found in a
    different directory from the CUDA DLLs. You may install the
    necessary DLL by downloading cuDNN 5.1 from this URL:
    https://developer.nvidia.com/cudnn

  • Could not find cuDNN.

Please Help !!!!!!

@Walt3r1

This comment has been minimized.

Copy link

Walt3r1 commented Jul 15, 2018

I have similar problem. I have a previous version of python 2.7 so I downloaded 3.5.4 Next I installed tensorflow using pip3 install --upgrade tensorflow The message:

Installing collected packages: setuptools, numpy, six, markdown, wheel, protobuf, werkzeug, tensorboard, grpcio, gast, astor, absl-py, termcolor, tensorflow
Successfully installed absl-py-0.2.2 astor-0.7.1 gast-0.2.0 grpcio-1.13.0 markdown-2.6.11 numpy-1.14.5 protobuf-3.6.0 setuptools-39.1.0 six-1.11.0 tensorboard-1.9.0 tensorflow-1.9.0 termcolor-1.1.0 werkzeug-0.14.1 wheel-0.31.1
When trying to confirm installation i get:

import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\Walt\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Walt\AppData\Local\Programs\Python\Python35\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 985, in _gcd_import
File "", line 968, in _find_and_load
File "", line 957, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 938, in create_module
File "", line 222, in _call_with_frames_removed
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

When I run this command dir C:\Users\Walt\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python_pywrap_tensorflow.pyd I get:

Volume in drive C is OS_Install
Volume Serial Number is 14E0-9B9F

Directory of C:\Users\Walt\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python

File Not Found

What steps can I take from this point on to troubleshoot this issue?

Thank you.

@Walt3r1

This comment has been minimized.

Copy link

Walt3r1 commented Jul 20, 2018

After looking into this problem over few days I came across information that any tensorflow version that is >1.5 will not work with window. So my problem is solved. I downgraded to to 1.5. It's working. If you think this will help you then uninstall any previous version of TF and install the 1.5 version using this command:

pip3 uninstall tensorflow
pip3 install --upgrade --ignore-installed tensorflow==1.5

@tsotsotso

This comment has been minimized.

Copy link

tsotsotso commented Aug 16, 2018

this was very helpful @Walt3r1 ,to the point and quicker.

@nateGeorge

This comment has been minimized.

Copy link

nateGeorge commented Oct 6, 2018

@Walt3r1 where did you find this information? To me it looks like any version on windows should work: https://www.tensorflow.org/install/source_windows

@docrainbox

This comment has been minimized.

Copy link

docrainbox commented Nov 14, 2018

Could not even run the basic example after installing Tensorflow 1.10.0 with pip install command. Thanks to the suggestion here -- Installing the Microsoft Visual C++ 2015 Redistributable Update 3 (x64 version) -- problem was fixed and able to work with Tensorflow with Spark now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment