Python 没有名为“_pywrap_tensorflow_internal”的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/44080677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 23:43:03  来源:igfitidea点击:

No Module Named '_pywrap_tensorflow_internal'

pythonwindowsdlltensorflow

提问by Amit Agarwal

While trying to validate the installation of tensorflow-gpu, I get an ImportError when trying to execute "import tensorflow as tf". I am using a Quadro K620 on Windows 7. Tensorflow was installed using pip.

在尝试验证 tensorflow-gpu 的安装时,我在尝试执行“import tensorflow as tf”时收到 ImportError。我在 Windows 7 上使用 Quadro K620。Tensorflow 是使用 pip 安装的。

The following is the stack trace:

以下是堆栈跟踪:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\aagarwal>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_hel
per
    return importlib.import_module(mname)
  File "C:\Users\aagarwal\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: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_hel
per
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Users\aagarwal\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'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\__init__.py", line 51, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_hel
per
    return importlib.import_module(mname)
  File "C:\Users\aagarwal\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: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_hel
per
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Users\aagarwal\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_probl
ems

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

I have looked at multiple other stack overflow posts which things like correcting the path but I have not been able to solve this issue.

我查看了多个其他堆栈溢出帖子,例如更正路径,但我无法解决此问题。

采纳答案by GoingMyWay

I came across the same issue today, please switch to cuDNN v5.1 Library for Windows instead as @mickdelaney suggested and then try to

我今天遇到了同样的问题,请切换到 Windows 的 cuDNN v5.1 库,而不是像 @mickdelaney 建议的那样,然后尝试

  1. Check environment settings of CUDA, normally all the settings of CUDA had been added to Windows environment

  2. Copy files in bin, liband includeof cuDNN to bin, liband includeof CUDA respectively. Normally the directory is C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA

  1. 检查CUDA的环境设置,通常CUDA的所有设置都已添加到Windows环境中

  2. 在复制文件binlibincludecuDNN来binlibincludeCUDA的分别。通常目录是C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA

And then you can import tensorflow and run your code. Good luck!

然后你可以导入 tensorflow 并运行你的代码。祝你好运!

回答by EKNATH KULKARNI

I found the solution for the CPU: It worked for me

我找到了 CPU 的解决方案:它对我有用

Just run below command if necessary then update it

如有必要,只需运行以下命令然后更新它

pip install tensorflow==1.5

pip install tensorflow==1.5

回答by Mars Marcin

you could uninstall the current version of tensorflow and try a low version such as TensorFlow 0.12 using the code

您可以卸载当前版本的 tensorflow 并使用代码尝试低版本,例如 TensorFlow 0.12

pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-0.12.0rc0-cp35-cp35m-win_amd64.whl

https://blog.csdn.net/baidu_36669549/article/details/79734590

https://blog.csdn.net/baidu_36669549/article/details/79734590

回答by WHCer

After you install the CUDA Drivers you must download cuDNN and release it. After that you get to copy the cudnn64_5.dllto PATH.
If that doesn't work, move the cudnn64_5.dllto NVIDIA GPU Computing Toolkit\CUDA\v8.0\binand try it again. Otherwise you'd meet some error that you see.

安装 CUDA 驱动程序后,您必须下载 cuDNN 并发布它。之后,您可以将其复制cudnn64_5.dll到 PATH。
如果不起作用,移动cudnn64_5.dllNVIDIA GPU Computing Toolkit\CUDA\v8.0\bin并再次尝试。否则你会遇到一些你看到的错误。

回答by mickdelaney

回答by cemsazara

I had the same error with anaconda, it was previously installed with another program through anaconda. Installing again through conda-forgeworked: conda install -c conda-forge tensorflow

我对 anaconda 有同样的错误,它以前是通过 anaconda 与另一个程序一起安装的。通过conda-forge工作再次安装: conda install -c conda-forge tensorflow

回答by stpaulchuck

this is all about your video chip/card and CPU compatibility with TF VERSION! Current version of Tensor Flow is 1.8 and it crashes on both my machines.

这完全是关于您的视频芯片/卡和 CPU 与 TF VERSION 的兼容性!当前版本的 Tensor Flow 是 1.8,它在我的两台机器上都崩溃了。

I have a win7 Gateway notebook using an I5 CPU and intel video chip. I have a desktop win7 unit with AMD Phenom II and AMD Radeon HD5450 video card. The I5 notebook requires V1.6 of TensorFlow and the desktop AMD unit takes V1.5. I don't have a GPU available for running ANN's so I don't know how that would affect it.

我有一台使用 I5 CPU 和英特尔视频芯片的 win7 网关笔记本电脑。我有一台带有 AMD Phenom II 和 AMD Radeon HD5450 显卡的台式机 win7 设备。I5 笔记本需要 TensorFlow V1.6,台式机 AMD 单元需要 V1.5。我没有可用于运行 ANN 的 GPU,所以我不知道这会如何影响它。

Here's the command line for PIP install: pip install --upgrade tensorflow==1.5.0 (or whatever other version you need). This will uninstall your current version and then install the indicated version.

这是 PIP 安装的命令行: pip install --upgrade tensorflow==1.5.0(或您需要的任何其他版本)。这将卸载您当前的版本,然后安装指定的版本。

Build or copy a small TensorFlow script and run it in a command window. Open a second command window and install a different version. I'd recommend starting at 1.5 and working your way up.

构建或复制一个小的 TensorFlow 脚本并在命令窗口中运行它。打开第二个命令窗口并安装不同的版本。我建议从 1.5 开始,然后逐步提高。

回答by maniac

The only thing that worked for me (Windows 10) is: Install Microsoft Visual C++ 2015 Redistributable Update 3If you have a new fresh computer setup this one might miss.

唯一对我有用的东西(Windows 10)是:安装Microsoft Visual C++ 2015 Redistributable Update 3如果你有一台新的电脑设置,这个可能会错过。

回答by aldel

I still got this error after installing cuDNN 5.1 (yes, I had PATH set correctly). I had better luck installing tensorflow_gpu from this site. This requires cuDNN 6.0, not 5.1. Unfortunately they currently only have Tensorflow 1.1 for GPU systems.

安装 cuDNN 5.1 后我仍然收到此错误(是的,我正确设置了 PATH)。我有幸从这个站点安装 tensorflow_gpu 。这需要 cuDNN 6.0,而不是 5.1。不幸的是,他们目前只有用于 GPU 系统的 Tensorflow 1.1。

回答by Paul

I am a chinese, so my english is poor, and my answer is that however you use cudnn 7 or 6 or 5 , you must rename the dll from cudnn64_x.dll to cudnn64_6.dll after you copy files. maybe soon, you need to rename the dll to 7 or 8 or 9 as possible.

我是中国人,所以我的英语很差,我的回答是,无论您使用 cudnn 7 或 6 还是 5 ,您都必须在复制文件后将 dll 从 cudnn64_x.dll 重命名为 cudnn64_6.dll。也许很快,您需要尽可能将 dll 重命名为 7 或 8 或 9。