所以我在使用我的mac上运行tensorflow时遇到了一些麻烦。 我查看了当前版本的python并运行了安装。 从结果我可以清楚地看到它已经存在:
$ python --version
Python 3.4.3 :: Anaconda 2.3.0 (x86_64)
$ pip3 install tensorflow
Requirement already satisfied: tensorflow in
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requirement already satisfied: six>=1.10.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from tensorflow)
Requirement already satisfied: protobuf>=3.1.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from tensorflow)
Requirement already satisfied: numpy>=1.11.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from tensorflow)
Requirement already satisfied: wheel>=0.26 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from tensorflow)
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from protobuf>=3.1.0->tensorflow)
Requirement already satisfied: appdirs>=1.4.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from setuptools->protobuf>=3.1.0->tensorflow)
Requirement already satisfied: packaging>=16.8 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from setuptools->protobuf>=3.1.0->tensorflow)
Requirement already satisfied: pyparsing in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from packaging>=16.8->setuptools->protobuf>=3.1.0->tensorflow)
但是当我运行python并尝试导入模块时,它无法找到。为什么会这样?
$ python
Python 3.4.3 |Anaconda 2.3.0 (x86_64)| (default, Mar 6 2015, 12:07:41)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'tensorflow'
编辑:我尝试做了什么wpercy建议并得到错误
PermissionError: [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/wheel/__init__.py'
然后我尝试了
sudo pip3 install --ignore-installed --upgrade $TF_BINARY_URL
这个没有给我一个错误,但我收到了这个警告:
The directory '/Users/daltyboy11/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/daltyboy11/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
它安装成功,但是当我尝试在python中导入它时,模块无法识别。这个警告是否与它有关?
好吧,所以我终于让它工作了,它要求我在conda环境中进行安装(来自tensorflow文档中的说明):
$ conda create -n tensorflow python=3.4
$ source activate tensorflow
(tensorflow)$ # Your prompt should change
# Linux/Mac OS X, Python 2.7/3.4/3.5, CPU only:
(tensorflow)$ conda install -c conda-forge tensorflow
但是现在如果我想使用tensorflow我需要激活这个conda环境......这没关系...但它仍然无法解决我原来的问题。有谁知道如何在conda环境之外使用张量流?
由于