python - 为什么在我的 IDLE 上导入 Tensorflow 会导致错误?
问题描述
这是我不断得到的代码。我通过 pip 安装了 TensorFlow,但必须使用链接而不是传统方法(它不起作用)。最后的链接也失效了...
我安装任何其他库没有太大困难。Numpy、Pandas 和其他人似乎运行良好。但是,当我安装 tensorflow 时,它确实给了我一个警告,说我应该考虑将它添加到 PATH,但在我这样做之前,安装已经完成。我应该怎么办?
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "C:\Users\devas\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow', [dirname(__file__)])
File "C:\Program Files (x86)\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\devas\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\__init__.py", line 66, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\devas\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\devas\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
ModuleNotFoundError: No module named '_pywrap_tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import tensorflow
File "C:\Users\devas\AppData\Roaming\Python\Python38\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\devas\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\devas\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow', [dirname(__file__)])
File "C:\Program Files (x86)\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\devas\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\__init__.py", line 66, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\devas\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\devas\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
ModuleNotFoundError: No module named '_pywrap_tensorflow'
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
解决方案
I guess it has to do with the version you are using or You could change the versions of either Python or Tensorflow, as these 2 versions you are using are not compatible. You could downgrade to Python3.6 or try Tensorflow>=1.13.1 which supports Python 3.7.
推荐阅读
- jenkins - 是否可以将包含 jenkinsfile 的存储库与包含代码的存储库分开
- javascript - 在javascript中拖放时,Md5总是相同的哈希
- firebase - 如何通过 @nuxtjs/pwa 插件使用 Firebase 云消息进行网络推送?
- postgresql-11 - How to convert text field with formatted currency to numeric field type in Postgres?
- pandas - Pandas 列在最后一行中的给定值
- sql - Union specific columns from 3 tables with different number of columns
- java - 在 XML 中使其无法解析
- django - What does JWT being stateless really means?
- ssh - One liner ssh different enviroment variables than normal ssh
- date - 在雪花中转换日期