【问题标题】:Why does importing Tensorflow on my IDLE cause an error?为什么在我的 IDLE 上导入 Tensorflow 会导致错误?
【发布时间】:2020-11-16 04:34:09
【问题描述】:

这是我不断获得的代码。我通过 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.

【问题讨论】:

    标签: python tensorflow pip tensorflow2.0 python-idle


    【解决方案1】:

    我想这与您使用的版本有关,或者您可以更改 Python 或 Tensorflow 的版本,因为您使用的这两个版本不兼容。您可以降级到 Python3.6 或尝试支持 Python 3.7 的 Tensorflow>=1.13.1。

    【讨论】:

    • 另一个问题是我也无法下载最新的 Tensorflow 版本。这就是为什么我不得不使用另一个堆栈溢出建议通过 google api 链接下载 TF。
    猜你喜欢
    • 2019-04-11
    • 2020-11-05
    • 2017-07-01
    • 1970-01-01
    • 2017-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多