python - 尝试在 python 3.7 上导入 keras 时出错
问题描述
一直在尝试在本地运行一些 ml 模型,每当我import keras
在 python 中使用时,我都会收到此错误。我正在使用带有python 3.7
. 这是错误:
Using TensorFlow backend.
Traceback (most recent call last):
File "D:\Python\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 "D:\Python\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 "D:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\Python\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 "<pyshell#0>", line 1, in <module>
import keras
File "D:\Python\lib\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "D:\Python\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "D:\Python\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "D:\Python\lib\site-packages\keras\backend\__init__.py", line 89, in <module>
from .tensorflow_backend import *
File "D:\Python\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "D:\Python\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "D:\Python\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "D:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "D:\Python\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 "D:\Python\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 "D:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\Python\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.
解决方案
尝试这个:
从 tensorflow.python 导入 keras
推荐阅读
- java - 运行 R 刮板脚本时出现 java.io.IOException 错误
- javascript - 向表格的每一行添加按钮以删除所述行
- r - 堆积条形图:如何使用 forcats 包排列组
- javascript - fs-extra 抛出错误:EBUSY:资源繁忙或锁定
- android - Android 仅在 90 秒后尝试获取位置
- javascript - SyntaxError: await 仅在异步函数中有效
- java - 从基于 Java 的应用程序访问 .NET DLL,服务包装器是否可以接受?
- java - 使用 Spring Boot 在 Java 中发送异步 HTTP 请求
- unity3d - 刚体通过 addForce 移动,但对象本身不移动
- laravel - 如何导入字体 laravel markdown?