我正在运行一个Python文件来训练一个神经网络。该文件来自第三个来源,因此应该是正确的。当从IDLE Python运行它时,我得到以下错误,但我不明白我做错了什么?
我使用Python 3.9.2和pip安装tensorflow, keras.
谢谢!
Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
= RESTART: C:UsersUserAppDataRoamingMetaQuotesTerminalCommonFilesEURUSDPyTren.py
Traceback (most recent call last):
File "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:UsersUserAppDataLocalProgramsPythonPython39libimp.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 "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagestensorflowpythonpywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagestensorflowpythonpywrap_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 "C:UsersUserAppDataRoamingMetaQuotesTerminalCommonFilesEURUSDPyTren.py", line 3, in <module>
import tensorflow as tf
File "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagestensorflow__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagestensorflowpython__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagestensorflowpythonpywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:UsersUserAppDataLocalProgramsPythonPython39libimp.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 "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagestensorflowpythonpywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagestensorflowpythonpywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:UsersUserAppDataLocalProgramsPythonPython39libsite-packagestensorflowpythonpywrap_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到最新版本
pip install tensorflow==2.4.1
https://pypi.org/project/tensorflow/
也切换到cuDNN 5.1
https://github.com/tensorflow/tensorflow/issues/7705