user3554354
user3554354

Reputation: 51

Tensorflow 1.7- Windows- No module named pywrap

I know people asked this question before. I believe I tried everything written in other StackOverflow questions (On Windows, running "import tensorflow" generates No module named "_pywrap_tensorflow" error). The new TensorFlow 1.7 requires CUDA Toolkit 9.0 and cuDNN v7.0 (both of which I added to my environment path). I also installed the latest version of Visual Studio 17. I reinstalled Python 3.5; Anaconda; CUDA Toolkit 9.0; cuDNN v7.0. Do you think its because of the new VS studio isn't compatible?

This is the error I get:

 import tensorflow as tf
Traceback (most recent call last):
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
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 "<stdin>", line 1, in <module>
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *  # pylint: disable=redefined-builtin
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Program Files\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

Upvotes: 0

Views: 759

Answers (1)

Marek Sawicki
Marek Sawicki

Reputation: 44

This error might be caused because of generation of your processor. I struggled with the same error for CPU mode only. Checked for 2 machines: win 7 pro, i7 1366 socket and win 7 home with i5 1366 socket with the same output. The problem is that Tensorflow r1.7 seems to require AVX support. Check does your processor support AVX if not switch to Tensor Flow 1.5

For native instalation (python 3.5 or python 3.6)(Tensor Flow r1.5 CPU)

pip3 install tensorflow==1.5

For anaconda (Tensor Flow r1.5 CPU)

conda create -n your_env_name pip python=3.5 (or 3.6)

in next line

activate your_env_name

and finally install Tensorflow 1.5

pip install --ignore-installed tensorflow==1.5

For me two ways work on 2 machines without problems. I have no idea if you are dealing with GPU because I am new and my graphics is not powerfull enough to use.

Enjoy!

Upvotes: 2

Related Questions