On Windows, running “import tensorflow” generates No module named “_pywrap_tensorflow” error

后端 未结 23 3279
误落风尘
误落风尘 2020-11-22 06:55

On Windows, TensorFlow reports either or both of the following errors after executing an import tensorflow statement:

  • No module named \"_pyw
相关标签:
23条回答
  • 2020-11-22 07:23

    Dll not found. Install Visual C++ 2015 redistributable to fix.

    0 讨论(0)
  • 2020-11-22 07:24

    The problem was the cuDNN Library for me - for whatever reason cudnn-8.0-windows10-x64-v6.0 was NOT working - I used cudnn-8.0-windows10-x64-v5.1 - ALL GOOD!

    My setup working with Win10 64 and the Nvidia GTX780M:

    • Be sure you have the lib MSVCP140.DLL by checking your system/path - if not get it here
    • Run the windows installer for python 3.5.3-amd64 from here - DO NOT try newer versions as they probably won't work
    • Get the cuDNN v5.1 for CUDA 8.0 from here - put it under your users folder or in another known location (you will need this in your path)
    • Get CUDA 8.0 x86_64 from here
    • Set PATH vars as expected to point at the cuDNN libs and python (the python path should be added during the python install)
    • Make sure that ".DLL" is included in your PATHEXT variable
    • If you are using tensorflow 1.3 then you want to use cudnn64_6.dll github.com/tensorflow/tensorflow/issues/7705

    If you run Windows 32 be sure to get the 32 bit versions of the files mentioned above.

    0 讨论(0)
  • I have Win7 Pro 64-bit on AMD cpu, no gpu. I was following the instructions under "Installing with native pip" at https://www.tensorflow.org/install/install_windows. The installation step went ok but the attempt to import tensorflow produced the infamous:

    ImportError: No module named '_pywrap_tensorflow_internal'
    

    This seems to be one of those situations where a lot of unrelated things can go wrong, depending on configuration, which all cascade through to the same error.

    In my case, installing MSVCP140.DLL was the answer.

    You have MSVCP140.DLL already if

    1. you have a file C:\Windows\System32\MSVCP140.DLL, AND
    2. if you have a 64 bit system, then you additionally have C:\Windows\SysWOW64\MSVCP140.DLL.

    I installed it manually, which was unnecessary (the redistributable is not the whole Visual C++ development mess and isn't large). Use the link posted earlier in this thread to install it: Visual C++ 2015 redistributable.

    Also, I recommend that you override the default install directory for Python and put it anywhere not under C:\Program Files, because Windows tries to write-protect files there, which causes problems later.

    0 讨论(0)
  • 2020-11-22 07:28

    Either error indicates that your system has not installed MSVCP140.DLL, which TensorFlow requires.

    To fix this error:

    1. Determine whether MSVCP140.DLL is in your %PATH% variable.
    2. If MSVCP140.DLL is not in your %PATH%, install the Visual C++ 2015 redistributable (x64 version), which contains this DLL.
    0 讨论(0)
  • 2020-11-22 07:29

    cuDNN causes my problem. PATH variable doesn't work for me. I have to copy the files in my cuDNN folders into respectful CUDA 8.0 folder structure.

    0 讨论(0)
  • 2020-11-22 07:29

    I posted a general approach for troubleshooting the "DLL load failed" problem in this post on Windows systems. For reference:

    1. Use the DLL dependency analyzer Dependencies to analyze <Your Python Dir>\Lib\site-packages\tensorflow\python\_pywrap_tensorflow_internal.pyd and determine the exact missing DLL (indicated by a ? beside the DLL). The path of the .pyd file is based on the TensorFlow 1.9 GPU version that I installed. I am not sure if the name and path is the same in other TensorFlow versions.

    2. Look for information of the missing DLL and install the appropriate package to resolve the problem.

    0 讨论(0)
提交回复
热议问题