tensorflow: Tensorflow 1.6.0 cpu fails on import on Windows 10

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No, problem appears on import (import tensorflow as tf).
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 x64
  • TensorFlow installed from (source or binary): binary (pip --no-cache-dir) install --upgrade tensorflow
  • TensorFlow version (use command below): 1.6.0 (install says tensorflow-1.6.0-cp36-cp36m-win_amd64.whl)
  • Python version: 3.6.4 x64
  • Bazel version (if compiling from source): n/a
  • GCC/Compiler version (if compiling from source): n/a
  • CUDA/cuDNN version: n/a
  • GPU model and memory: n/a
  • Exact command to reproduce: import tensorflow as tf

You can collect some of this information using our environment capture script:

https://github.com/tensorflow/tensorflow/tree/master/tools/tf_env_collect.sh

You can obtain the TensorFlow version with

python -c “import tensorflow as tf; print(tf.GIT_VERSION, tf.VERSION)”

Describe the problem

When installing tensorflow 1.6.0 the import reports problems. See log below. Tried uninstalled r1.6 and reinstalled 1.5.0 to see if something else might be the problem. 1.5.0 works like a charm. Tried a clean install of 1.6.0 without any luck.

Ran the ‘tensorflow_self_check.py’ script. See log below.

Source code / logs

Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "C:\Users\Jonas\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\Jonas\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Jonas\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Jonas\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Jonas\AppData\Local\Programs\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:\Users\Jonas\AppData\Local\Programs\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 "<stdin>", line 1, in <module>
  File "C:\Users\Jonas\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:\Users\Jonas\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\Jonas\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\Jonas\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\Jonas\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 571, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Jonas\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Jonas\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Jonas\AppData\Local\Programs\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:\Users\Jonas\AppData\Local\Programs\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.



------------------------

When running 'tensorflow_self_check.py' this is what is reported. Supposed to have installed the CPU version so cuda is not installed.

ERROR: Failed to import the TensorFlow module.

- Python version is 3.6.

- TensorFlow is installed at: C:\Users\Jonas\AppData\Local\Programs\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 '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.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 46 (4 by maintainers)

Most upvoted comments

The CPU lack AVX instruction can cause this error.

I have built tensorflow wheel without AVX.

https://github.com/fo40225/tensorflow-windows-wheel/tree/master/1.6.0/py36/CPU/sse2

I wish this .whl may help you.

and yet another guy reported this UNDOCUMENTED problem And the whl-solution doe snot work : is not a supported wheel on this platform

I had a similar problem and this worked for me

  1. Install anaconda
  2. Open anaconda prompt
  3. conda create -n tfp python=3.6
  4. activate tfp
  5. conda install tensorflow
  6. python
  7. import tensorflow

If it works and you are using PyCharm go to File -> Settings ->Project Interpreter Click on top right button ->Add (Project Interpreter) -> Conda Environment ->Existing environment Choose --path–\Anaconda3\envs\tfp\python.exe

I have AMD Ryzen 1600 CPU which supports both AVX and AVX2, and I cannot use the CPU version of Tensorflow either.

Stacktrace:

Using TensorFlow backend.
Usage: python -m flask run [OPTIONS]

Error: While importing "app", an ImportError was raised:

Traceback (most recent call last):
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
  File "C:\Users\Angius\AppData\Local\Programs\Python\Python36-32\lib\imp.py", line 297, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\flask\cli.py", line 240, in locate_app
    __import__(module_name)
  File "C:\Users\Angius\PycharmProjects\LNNameGen\app.py", line 2, in <module>
    from textgenrnn import textgenrnn
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\textgenrnn\__init__.py", line 1, in <module>
    from .textgenrnn import textgenrnn
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\textgenrnn\textgenrnn.py", line 1, in <module>
    from keras.callbacks import LearningRateScheduler, Callback
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\keras\__init__.py", line 3, in <module>
    from . import utils
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
    from . import conv_utils
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
    from .. import backend as K
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\keras\backend\__init__.py", line 89, in <module>
    from .tensorflow_backend import *
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
    import tensorflow as tf
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
  File "C:\Users\Angius\AppData\Local\Programs\Python\Python36-32\lib\imp.py", line 297, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Angius\PycharmProjects\LNNameGen\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

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

Can’t install the provided alternative wheel either, because

tensorflow-1.6.0-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.

AMD Phenom II x4 955BE for me, which does indeed lack AVX support. These unlisted requirements (AVX support, VC++2015, etc.) are rather frustrating…

@fo40225’s wheel does fix the issue though!

run this code “import tensorflow as tf” and it report below errors:

ImportError Traceback (most recent call last) D:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module> 57 —> 58 from tensorflow.python.pywrap_tensorflow_internal import * 59 from tensorflow.python.pywrap_tensorflow_internal import version

D:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module> 34 return _mod —> 35 _pywrap_tensorflow_internal = swig_import_helper() 36 del swig_import_helper

D:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper() 29 try: —> 30 _mod = imp.load_module(‘_pywrap_tensorflow_internal’, fp, pathname, description) 31 finally:

D:\Anaconda3\lib\imp.py in load_module(name, file, filename, details) 241 else: –> 242 return load_dynamic(name, filename, file) 243 elif type_ == PKG_DIRECTORY:

D:\Anaconda3\lib\imp.py in load_dynamic(name, path, file) 341 name=name, loader=loader, origin=path) –> 342 return _load(spec) 343

ImportError: DLL load failed with error code -1073741795

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last) <ipython-input-6-8c0c2a0e5106> in <module> ----> 1 import tensorflow as tf 2 # https://www.lfd.uci.edu/~gohlke/pythonlibs/#xgboost

D:\Anaconda3\lib\site-packages\tensorflow_init_.py in <module> 20 21 # pylint: disable=g-bad-import-order —> 22 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import 23 from . import app 24 from . import bitwise

D:\Anaconda3\lib\site-packages\tensorflow\python_init_.py in <module> 47 import numpy as np 48 —> 49 from tensorflow.python import pywrap_tensorflow 50 51 # Protocol buffers

D:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module> 72 for some common reasons and solutions. Include the entire stack trace 73 above this error message when asking for help.“”" % traceback.format_exc() —> 74 raise ImportError(msg) 75 76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback (most recent call last): File “D:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py”, line 58, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File “D:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”, line 35, in <module> _pywrap_tensorflow_internal = swig_import_helper() File “D:\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”, line 30, in swig_import_helper _mod = imp.load_module(‘_pywrap_tensorflow_internal’, fp, pathname, description) File “D:\Anaconda3\lib\imp.py”, line 242, in load_module return load_dynamic(name, filename, file) File “D:\Anaconda3\lib\imp.py”, line 342, in load_dynamic return _load(spec) ImportError: DLL load failed with error code -1073741795

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.

my python is Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32

my computer is Intel® Core™ i3 CPU 64bit with win7 Service Pack 1

i have tried many different solutions but they still won’t work. Anybody has met the same problem?

ok, success! I uninstalled and re-installed the .whl by @fo40225 using the --upgrade flag and it worked! Thanks