我检查了我的pip3和python3版本:
(tensorflow) MacBook-Pro-de-Hector-2:tensorflow hectoresteban$ pip3 -V
pip 10.0.1 from /Users/hectoresteban/.virtualenvs/tensorflow/lib/python3.7/site-packages/pip-10.0.1-py3.7.egg/pip (python 3.7)
(tensorflow) MacBook-Pro-de-Hector-2:tensorflow hectoresteban$ python3 -V
Python 3.7.0
在我当前使用的虚拟环境中,我执行了以下操作:
pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.9.0-py3-none-any.whl
作为标准方式,pip3 install tensorflow
输出以下信息:
could not find a version that satisfies the requirement tensorflow (from versions: )
使用第一种方法安装后:
(tensorflow) MacBook-Pro-de-Hector-2:tensorflow hectoresteban$ python3
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/hectoresteban/.virtualenvs/tensorflow/lib/python3.7/site-packages/tensorflow/__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Users/hectoresteban/.virtualenvs/tensorflow/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Users/hectoresteban/.virtualenvs/tensorflow/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/hectoresteban/.virtualenvs/tensorflow/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 114
def TFE_ContextOptionsSetAsync(arg1, async):
^
SyntaxError: invalid syntax
什么问题?我可以下载其他软件包,比如numpy,但是无法下载Tensorflow。(MacOS 10.13.4)
brew remove python3
,然后运行brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
。 - hoeflingasync
在Python 3.7中成为了保留关键字。该代码适用于Python 3 <= 3.6。 - phd