Skip to content
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

No Module Named '_pywrap_tensorflow_internal' (still without working solution) #11571

Closed
StephanH84 opened this issue Jul 18, 2017 · 12 comments
Closed
Labels
type:build/install Build and install issues

Comments

@StephanH84
Copy link

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
    Yes, it is one general import command (see below).
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
    Windows 10
  • TensorFlow installed from (source or binary):
    From source (nightly build tensorflow_gpu-1.2.1-cp35-cp35m-win_amd64.whl from 2017/07/13).
  • TensorFlow version (use command below):
    1.2.1 (command does not work, it includes the failed command)
  • Python version:
    3.5.2
  • Bazel version (if compiling from source):
    Not compiled from source.
  • CUDA/cuDNN version:
    CUDA 8.0, cudnn64_5.dll (Windows file description is: NVIDIA CUDA CUDNN Library. Version 8.0.54)
  • GPU model and memory:
    GPU NVidia Geforce 1050
  • Exact command to reproduce:
    import tensorflow

Describe the problem

Importing TensorFlow causes an error:

$ ipython
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import tensorflow
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
c:\users\steph\appdata\local\programs\python\python35\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\steph\appdata\local\programs\python\python35\lib\importlib\__init__.py in import_module(name, package)
    125             level += 1
--> 126     return _bootstrap._gcd_import(name[level:], package, level)
    127

c:\users\steph\appdata\local\programs\python\python35\lib\importlib\_bootstrap.py in _gcd_import(name, package, level)

c:\users\steph\appdata\local\programs\python\python35\lib\importlib\_bootstrap.py in _find_and_load(name, import_)

c:\users\steph\appdata\local\programs\python\python35\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)

c:\users\steph\appdata\local\programs\python\python35\lib\importlib\_bootstrap.py in _load_unlocked(spec)

c:\users\steph\appdata\local\programs\python\python35\lib\importlib\_bootstrap.py in module_from_spec(spec)

c:\users\steph\appdata\local\programs\python\python35\lib\importlib\_bootstrap_external.py in create_module(self, spec)

c:\users\steph\appdata\local\programs\python\python35\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\steph\appdata\local\programs\python\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>()
     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\steph\appdata\local\programs\python\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module>()
     20             return importlib.import_module('_pywrap_tensorflow_internal')
---> 21     _pywrap_tensorflow_internal = swig_import_helper()
     22     del swig_import_helper

c:\users\steph\appdata\local\programs\python\python35\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\steph\appdata\local\programs\python\python35\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)
<ipython-input-1-a649b509054f> in <module>()
----> 1 import tensorflow

c:\users\steph\appdata\local\programs\python\python35\lib\site-packages\tensorflow\__init__.py in <module>()
     22
     23 # pylint: disable=wildcard-import
---> 24 from tensorflow.python import *
     25 # pylint: enable=wildcard-import
     26

c:\users\steph\appdata\local\programs\python\python35\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

c:\users\steph\appdata\local\programs\python\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>()
     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\steph\appdata\local\programs\python\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "c:\users\steph\appdata\local\programs\python\python35\lib\importlib\__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: Das angegebene Modul wurde nicht gefunden.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\steph\appdata\local\programs\python\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "c:\users\steph\appdata\local\programs\python\python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "c:\users\steph\appdata\local\programs\python\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:\users\steph\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_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.

Source code / logs

check_tensorflow.py produces:

$ python check_tensorflow.py
ERROR: Failed to import the TensorFlow module.

  • Python version is 3.5.

  • TensorFlow is installed at: C:\Users\Steph\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow

  • All required DLLs are present. Please open an issue on the
    TensorFlow GitHub page: https://github.com/tensorflow/tensorflow/issues

The issue was already reported to Stackoverflow:
Stackoverflow issue

@pjaehrling
Copy link

I'm getting the same error, with a different environment (Tensorflow r1.2, on a MacBook with OSX 10.12.5 and no GPU support). The installation works, but I'm getting errors, when I try to import TF in python.

Python 2.7.10 (default, Feb  7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import tensorflow as tf
  Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
  ImportError: Traceback (most recent call last):
  File "tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  ImportError: No module named pywrap_tensorflow_internal


Failed to load the native TensorFlow runtime.

I'm working in a virtualenv (using virtualenvwrapper) with up-tp-date packages

  • virtualenv 15.1.0
  • python 2.7.10
  • pip 9.0.1
  • numpy 1.13.1
  • wheel 0.29.0
  • six 1.10.0

I tried to install the default pip package using pip install tensorflow and tried to install tensorflow from source following the installation tutorial, without CUDA support. Building and installing reported no errors, but in both cases I got the import error.

Related issues/questions (Github/Stackoverflow) and their answers pointed out problems with CUDA or missing Windows dll files, which do not seem to fit here.

@jubjamie
Copy link
Contributor

@StephanH84 This is a common error that's usually related to missing DLLs and your system Path not being configured correctly.
I see you are trying to install on Windows, @mrry has a great installation troubleshooter script that can help pinpoint issues available here: mrry's Self-check Script. It will help pinpoint the missing DLLs.

Also in your issue filing you say that you've installed from source but then list a nightly binary and say you've not compiled from source. Can I assume that you installed using a binary via pip? If so may I suggest uninstalling and installing straight from Pypi pip install tensorflow. Try the CPU version first in a separate environment. This can help troubleshooting to ensure it's nothing to do with CUDA!

Let us know how you get on. Good luck!

@pjaehrling It might be best that you file a Stack Overflow issue as your issue appears to be separate (although similar!) due to the different operating system, different version of tensorflow. I have no experience with the Mac version so hopefully someone else will come and help you!

@drpngx
Copy link
Contributor

drpngx commented Jul 18, 2017

@mrry should we check in the script?

@drpngx drpngx added the stat:awaiting response Status - Awaiting response from author label Jul 18, 2017
@pjaehrling
Copy link

pjaehrling commented Jul 19, 2017

@jubjamie: I already posted my problem on stackoverflow, unfortunately I got no response yet.

https://stackoverflow.com/questions/45149129/tesorflow-on-osx-failed-to-load-the-native-tensorflow-runtime-no-module-named

@StephanH84
Copy link
Author

StephanH84 commented Jul 29, 2017

For me it was possibly solved by adding Visual Studio directories to Windows' path variable (C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\bin\amd64, C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\bin) and then reinstalling tensorflow-gpu via pip (but here it took a version from cache):

2017-07-30 00:17:56.950667: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:940] Found device 0 with properties: 
name: GeForce GTX 1050
major: 6 minor: 1 memoryClockRate (GHz) 1.493
pciBusID 0000:01:00.0
Total memory: 4.00GiB
Free memory: 3.34GiB
2017-07-30 00:17:56.950921: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:961] DMA: 0 
2017-07-30 00:17:56.951039: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:971] 0:   Y 
2017-07-30 00:17:56.951192: I c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1050, pci bus id: 0000:01:00.0)

There were some issues at the start as comments:

2017-07-30 00:17:55.078289: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-07-30 00:17:55.078709: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-30 00:17:55.079111: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-30 00:17:55.079352: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-30 00:17:55.079600: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-30 00:17:55.079830: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-07-30 00:17:55.080102: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-30 00:17:55.080397: W c:\tf_jenkins\home\workspace\release-win\m\windows-gpu\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.

Apart from that at least for my issue "this issue" can be closed.

@jubjamie
Copy link
Contributor

Those are just warnings to do with possible ways to improve performance if compiling from source. They are normal and can be ignored. If you're happy the issue is solved you can close it yourself!

@aselle aselle removed the stat:awaiting response Status - Awaiting response from author label Jul 31, 2017
@pjaehrling
Copy link

@jubjamie should I open another issue? I couldn't find a way to make it work nor got a response to my Stack Overflow issue so far. I also tried to install tensorflow outside of the virtualenv and tried to build a pip wheel from source for the latest release version 1.3, but got the same error.

When I build the .whl file, I get warnings, which may seem to point to the problem?

▶ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
Wed Aug 2 17:05:01 CEST 2017 : === Using tmpdir: /var/folders
...
Wed Aug 2 17:05:07 CEST 2017 : === Building wheel
warning: no files found matching '*.dll' under directory '*'
warning: no files found matching '*.lib' under directory '*'
warning: no files found matching '*.h' under directory 'tensorflow/include/tensorflow'
warning: no files found matching '*' under directory 'tensorflow/include/Eigen'
warning: no files found matching '*' under directory 'tensorflow/include/external'
warning: no files found matching '*.h' under directory 'tensorflow/include/google'
warning: no files found matching '*' under directory 'tensorflow/include/third_party'
warning: no files found matching '*' under directory 'tensorflow/include/unsupported'

@jubjamie
Copy link
Contributor

jubjamie commented Aug 3, 2017

You're best off opening a separate issue to @StephanH84 if you have a different problem. In the new issue be sure to fill out the full template and also link and Stack Overflow questions you're already filed.

@blistergeist
Copy link

I just wrestled with this for a couple hours (Windows 10, Anaconda 4.4.0 64 bit). I had been trying to install tensorflow-gpu using pip with no success. I followed all the guides I could find, tried using Python 3.5.3, installed cudnn 5.1 and 6.0, tried different combinations using conda environments, and still ran into the same error.

I found that installing via conda rather than pip worked the first time. Conda installed cudatoolkit, cudnn, libprotobuf, and protobuf and updated itself and vs2015_runtime.

Apparently conda is better at putting all this stuff in the right place than I am. Praise conda.

@rohit-ptl
Copy link

rohit-ptl commented Jan 14, 2018

Had the same problem. Resolved using CUDA 9.0 and tf-nightly-gpu as suggested above. I have put up instructions here: https://github.com/rohit-patel/Install_Instructions-Win10-Deeplearning-Keras-Tensorflow

@hustc12
Copy link

hustc12 commented Mar 28, 2018

I meet this issue too. I installed anaconda on my Windows10 system. I tried to install TF through conda channel, it was OK at that time, however, the version of TF was 1.2.1, which I thought it was too old, besides, the instructions on tensorflow.org said TF installed via conda channel is not supported officially. So I switched to the official installation via the command: pip install tensorflow, however, the issue raised up.
I am just wondering why I still encounter this issue when followed the instructions to install TF.

@Joseph7ee
Copy link

Joseph7ee commented Mar 17, 2019

Windows 10, conda env,
resolved using wheel file guided here: https://www.tensorflow.org/install/pip
pip install https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.12.0-cp36-cp36m-win_amd64.whl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests

10 participants