【问题标题】:Installing Tensorflow on Windows 10 with Python 3.7.0 in PyCharm IDE在 PyCharm IDE 中使用 Python 3.7.0 在 Windows 10 上安装 Tensorflow
【发布时间】:2019-02-09 20:01:20
【问题描述】:

我正在尝试在带有JetBrains PyCharm Community Edition 5.0.4 IDE 和Python 3.7.0 的Windows 10 64 位操作系统上使用Tensorflow。我已将https://github.com/MicrocontrollersAndMore/TensorFlow_Tut_1_Installation_and_First_Progs 克隆到我的目录中。在我使用Python 3.5.1 之前,我已经将Environment Variables 中的PathProject Interpreter 中的File/Settings 更改为Python 3.7.0 (C:\Users\User\AppData\Local\Programs\Python\Python37-32\python.exe),所以基本的python 代码可以工作,但是当我尝试运行add_two_numbers_via_TensorFlow.py 代码时,其中包含import tensorflow as tf 它给出了错误:

"C:/Users/User/Desktop/TensorFlow/TensorFlow_Tut_1_Installation_and_First_Progs/add_two_numbers_via_TensorFlow.py", line 3, in <module>
    import tensorflow as tf ModuleNotFoundError: No module named 'tensorflow'

所以我必须使用Command Prompt Run as Administrator pip3 install --upgrade tensorflowpip3 install --upgrade tensorflow-gpu 安装,但错误是:

C:\WINDOWS\system32>pip3 install --upgrade tensorflow Collecting tensorflow   Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow

我不确定我必须安装什么,也许还有Python 3.6.x 64-bit

我也尝试安装python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl,但结果出现另一个错误:

  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\__init__.py", line 54, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
    import _pywrap_tensorflow
ModuleNotFoundError: No module named '_pywrap_tensorflow'

Error importing tensorflow.  Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.

编辑 1:

尝试从 PyCharm 安装 Python 3.6.6

Installing TensorFlow on Windows 说我必须为 Python 3.6 版本下载Anaconda。我不确定这是否是解决方案和错误原因

编辑 2:

Python-3.6.6-amd64.exe 属性,即Windows x86-64 executable installer

【问题讨论】:

    标签: python python-3.x tensorflow pycharm python-3.7


    【解决方案1】:

    TensorFlow 尚不可用于 Python 3.7。现在您可以返回到 Python 3.6 或 3.5 并查看this 了解更多信息。

    【讨论】:

    • 您好,我在使用 Python 3.5.1 时遇到了同样的错误(最后在我的问题帖子中)
    • 我不认为这是 Python 版本控制的问题,因为 Python 3.7 现在应该与 Tensorflow 一起使用。更有可能是 CUDA 和 cuDNN 问题,因为它是 tensorflow-gpu。
    【解决方案2】:

    我不确定你为什么需要python 3.7。但通常人们不会弄乱他们机器上安装的解释器。相反,他们创建了一个virtual environment。这使您可以拥有具有所需版本的 python 解释器。它还可以将您的所有包裹分开。您应该为每个项目创建一个新的virtual env。使用虚拟机,您不必以 root 身份运行任何东西,这很好,因为它更安全。

    Pycharm 让您在创建项目时创建一个,或者您可以转到 settings&gt;project&gt;project interpreter。通过单击齿轮图标,您可以将当前的解释器更改为另一个解释器,或者您可以创建一个新的 virtualenv。

    如果您使用的是 Pycharm,则可以通过特定的方式安装包。

    转到settings&gt;project&gt;project interpreter。在那里你可以点击+添加一个新的包,比如tensorflow

    【讨论】:

    • 您好,我在使用 Python 3.5.1 时遇到了同样的错误(最后在我的问题帖子中)
    • 您是尝试在 Pycharm 中安装它,还是再次使用 pip3 安装它?你应该使用 Pycharm。
    • 我用 Pycharm 的安装结果编辑了我的问题,结果是 Could not find a version that satisfies the requirement
    • 您的 python 是一个 32 位应用程序。 TensorFlow 只支持 64 位。
    • 我用 python-3.6.6-amd64.exe 属性的打印屏幕编辑了问题,看起来像 64 位
    【解决方案3】:

    我也有这个问题,我可以这样解决:

    pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org  pprint --proxy=http://username:password@doaminname.com:portnumber
    

    【讨论】:

    • 错误:由于环境错误而无法安装软件包:解析失败:doaminname.com:portnumber
    【解决方案4】:

    我无法使用 python 3.7 进行配置。使用 python 3.6。请使用上述虚拟环境,并确保在 PyCharm 设置的“项目解释器”中定义。

    这里有一些使用 3.6 进行配置的简单说明:

    configuring PyCharm for TensorFlow using python 3.6

    【讨论】:

    • 将说明作为文本添加到您的答案中,而不是屏幕截图。
    猜你喜欢
    • 2019-04-28
    • 2020-05-18
    • 2019-11-14
    • 2020-04-26
    • 2018-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-10
    相关资源
    最近更新 更多