【问题标题】:Problem importing Tensorflow with Python 3.6.7使用 Python 3.6.7 导入 TensorFlow 时出现问题
【发布时间】:2018-12-05 19:45:44
【问题描述】:

我在 Windows 10 上安装了 Anaconda3 和 Python 3.6.7,但是在导入 Tensorflow 时出现错误,所有详细描述和消息都附在下面: 我尝试将很多人说它与 Tensorflow 不兼容的 Python 3.7 更改为 3.6.7,但我仍然无法导入 Tensorflow,有谁知道我应该怎么做才能解决这个问题? //================================================= ========================

(tensorflow) C:\Users\user>python --version Python 3.6.7 :: Anaconda 自定义(64 位)

(tensorflow) C:\Users\user>python
Python 3.6.7 |Anaconda custom (64-bit)| (default, Oct 28 2018, 19:44:12) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "C:\Users\user\Anaconda3\envs\tensorflow\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\user\Anaconda3\envs\tensorflow\lib\imp.py", line 297, 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:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\user\Anaconda3\envs\tensorflow\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 "<stdin>", line 1, in <module>
  File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *  # pylint: disable=redefined-builtin
  File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\user\Anaconda3\envs\tensorflow\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\user\Anaconda3\envs\tensorflow\lib\imp.py", line 297, 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:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\user\Anaconda3\envs\tensorflow\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'

【问题讨论】:

    标签: python tensorflow installation anaconda


    【解决方案1】:

    我在具有相同 python 版本的 Windows 上遇到了类似的问题。请尝试以下步骤:

    1. 从 conda 环境中卸载现有的 TensorFlow
    2. 使用 conda 包管理器安装 TensorFlow 1.10.0 版。

      conda install tensorflow=1.10.0

    3. 安装完成后,确保包列表中有 3 个包:tensorflow、tensorflow-base 和 tensorboard。

    4. tensorflow-base 包可以解决这个问题。

    5. 最后安装 Microsoft Visual Studio C++ Redistributable。

    【讨论】:

      【解决方案2】:

      您可以尝试以下步骤:

      1. conda create --name tensorflow python=3.6

      2. 激活张量流

      3. conda install -c conda-forge tensorflow=1.0.0

      4. 尝试导入张量流

      5. 停用

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-03-20
        • 2018-12-04
        • 1970-01-01
        • 2012-12-24
        • 1970-01-01
        • 2019-01-07
        • 2021-05-10
        • 2019-12-07
        相关资源
        最近更新 更多