我正在尝试使用Tensorflow IDE和JetBrains PyCharm Community Edition 5.0.4在Windows 10 64位操作系统上使用Python 3.7.0。我已将https://github.com/MicrocontrollersAndMore/TensorFlow_Tut_1_Installation_and_First_Progs克隆到我的目录中。在我使用Python 3.5.1之前,所以我已经将Path
中的Environment Variables
和File/Settings
中的Project Interpreter
更改为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 tensorflow
或pip3 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:
尝试使用Python 3.6.6从PyCharm安装:
Installing TensorFlow on Windows说我必须下载Anaconda for Python 3.6版本。我不确定它是否是解决方案和错误原因
编辑2:
Python-3.6.6-amd64.exe属性,这是Windows x86-64 executable installer:
TensorFlow尚不适用于Python 3.7。现在您可以回到Python 3.6或3.5并查看this以获取更多信息。
我不确定你为什么需要python 3.7
。但通常人们不会在他们的机器上弄乱已安装的解释器。相反,他们创造了一个virtual environment
。这允许您拥有一个具有所需版本的python解释器。它还可以将您的所有包分开。你应该为每个项目创建一个新的virtual env
。使用虚拟机,您不必以root身份运行任何东西,因为它更安全。
Pycharm让你在创建项目时创建一个,或者你可以去settings>project>project interpreter
。通过单击齿轮图标,您可以将当前的解释器更改为另一个解释器,或者您可以创建新的virtualenv。
如果您使用Pycharm,则有一种特定的方法来安装软件包。
去settings>project>project interpreter
。在那里你可以点击+
添加一个像tensorflow
这样的新包。
我也有这个问题,我能够这样解决:
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pprint --proxy=http://username:[email protected]:portnumber