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

后端 未结 23 3667
误落风尘
误落风尘 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:27

    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.

提交回复
热议问题