python - 没有名为 '_pywrap_tensorflow_internal' 的模块错误

标签 python tensorflow image-recognition

我正在尝试运行以下代码:

import tensorflow
from imageai.Prediction.Custom import ModelTraining

model_trainer = ModelTraining()
model_trainer.setModelTypeAsResNet()
model_trainer.setDataDirectory("idenprof")
model_trainer.trainModel(num_objects=10, num_experiments=200, enhance_data=True, batch_size=32, show_network_summary=True)

但是我收到以下错误。它说没有模块名称_pywrap_tensorflow_internal。我也尝试导入 tensorflow 。但问题仍然存在。我该如何解决?我是 Python 新手,所以我可能错过了一些愚蠢的东西。

F:\Python\venv\Scripts\python.exe F:/Python/firstTraining.py
Traceback (most recent call last):
  File "F:\Python\venv\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:\Users\gautham.d\Python\Python38-32\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:

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

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "F:/Python/firstTraining.py", line 1, in <module>
    from imageai.Prediction.Custom import ModelTraining
  File "F:\Python\venv\lib\site-packages\imageai\Prediction\__init__.py", line 2, in <module>
    from tensorflow.python.keras.preprocessing import image
  File "F:\Python\venv\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "F:\Python\venv\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "F:\Python\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "F:\Python\venv\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:\Users\gautham.d\Python\Python38-32\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:

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


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

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

Process finished with exit code 1

最佳答案

这看起来像是一些 tensorflow 安装问题。通过卸载完全删除您的 python 和 TensorFlow。然后按照推荐的安装方式再次安装。

对于Python

对于Tensorflow

关于python - 没有名为 '_pywrap_tensorflow_internal' 的模块错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59784942/

相关文章:

python - Selenium Chrome Webdriver 无法在带有配置文件的 headless 模式下工作

python - Django2.1 : Queryset ModelChoice in a ModelForm then save two forms

python - 使用列表理解对嵌套在列表内的字典进行操作

python - 理解tensorflow中的 `tf.nn.nce_loss()`

tensorflow - 如何清理图像以与 MNIST 训练模型一起使用?

python - 显示评估选择的输出 - Sublime Text Python REPL

python - Keras 模型评估()与预测类()给出不同的精度结果

TensorFlow 服务 : "No assets to save/writes" when exporting models

machine-learning - 识别标志(品牌)的图像识别技术

使用 FFT 互相关进行 C++ 模式匹配(图像)