本文介绍了ModuleNotFoundError: 导入 tensorflow 后未显示名为“_pywrap_tensorflow_internal"的模块错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用这个 python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl 适用于 Windows 10 中的 python 3.8.

I have install tensor flow using this python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl for python 3.8 in windows 10.

在运行 import tensorflow as tf 后,它向我显示了回溯错误并且我无法使用 tensorflow ?我也安装了 CUDA 10.2 驱动程序.

After running import tensorflow as tf it shows me traceback error and I am not able to use tensorflow ?I have also installed CUDA 10.2 driver too.

回溯(最近一次调用最后一次):文件C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",第 18 行,在 swig_import_helperfp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)])文件C:\Python38\lib\imp.py",第 296 行,在 find_module 中引发导入错误(_ERR_MSG.format(名称),名称=名称)导入错误:没有名为_pywrap_tensorflow_internal"的模块

Traceback (most recent call last): File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)]) File "C:\Python38\lib\imp.py", line 296, in find_module raise ImportError(_ERR_MSG.format(name), name=name)ImportError: No module named '_pywrap_tensorflow_internal'

在处理上述异常的过程中,又发生了一个异常:

During handling of the above exception, another exception occurred:

回溯(最近一次调用最后一次):文件C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",第 58 行,在从 tensorflow.python.pywrap_tensorflow_internal 导入 *文件C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",第 28 行,在_pywrap_tensorflow_internal = swig_import_helper()文件C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",第 20 行,在 swig_import_helper导入 _pywrap_tensorflow_internalModuleNotFoundError: 没有名为_pywrap_tensorflow_internal"的模块

Traceback (most recent call last): File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper import _pywrap_tensorflow_internalModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

在处理上述异常的过程中,又发生了一个异常:

During handling of the above exception, another exception occurred:

回溯(最近一次调用最后一次):文件C:/Python38/Scripts/ArtificalNeuralNetwork/ANN.py",第 3 行,在将张量流导入为 tf文件C:\Python38\lib\site-packages\tensorflow__init__.py",第 24 行,在from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import文件C:\Python38\lib\site-packages\tensorflow\python__init__.py",第 49 行,在从 tensorflow.python 导入 pywrap_tensorflow文件C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",第 74 行,在引发导入错误(味精)导入错误:回溯(最近一次调用最后一次):文件C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",第 18 行,在 swig_import_helperfp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)])文件C:\Python38\lib\imp.py",第 296 行,在 find_module 中引发导入错误(_ERR_MSG.format(名称),名称=名称)导入错误:没有名为_pywrap_tensorflow_internal"的模块

Traceback (most recent call last): File "C:/Python38/Scripts/ArtificalNeuralNetwork/ANN.py", line 3, in import tensorflow as tf File "C:\Python38\lib\site-packages\tensorflow__init__.py", line 24, in from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import File "C:\Python38\lib\site-packages\tensorflow\python__init__.py", line 49, in from tensorflow.python import pywrap_tensorflow File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in raise ImportError(msg)ImportError: Traceback (most recent call last): File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)]) File "C:\Python38\lib\imp.py", line 296, in find_module raise ImportError(_ERR_MSG.format(name), name=name)ImportError: No module named '_pywrap_tensorflow_internal'

在处理上述异常的过程中,又发生了一个异常:

During handling of the above exception, another exception occurred:

回溯(最近一次调用最后一次):文件C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",第 58 行,在从 tensorflow.python.pywrap_tensorflow_internal 导入 *文件C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",第 28 行,在_pywrap_tensorflow_internal = swig_import_helper()文件C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",第 20 行,在 swig_import_helper导入 _pywrap_tensorflow_internalModuleNotFoundError: 没有名为_pywrap_tensorflow_internal"的模块

Traceback (most recent call last): File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "C:\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper import _pywrap_tensorflow_internalModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

无法加载本机 TensorFlow 运行时.

Failed to load the native TensorFlow runtime.

参见 https://www.tensorflow.org/install/errors

出于一些常见原因和解决方案.包括整个堆栈跟踪寻求帮助时出现在此错误消息上方.

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

推荐答案

引发此错误的一个非常常见的原因是没有下载 vs C++ 可再发行组件.

A very common reason for this error being thrown is not having vs C++ redistributables dowloaded.

在这里下载:https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

这篇关于ModuleNotFoundError: 导入 tensorflow 后未显示名为“_pywrap_tensorflow_internal"的模块错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 01:34