Enviorment :
Mac OSX 10.10
Python:2.7.10
我在尝试import tensorflow
Python 2.7.10 (default, Jul 14 2015, 19:46:27)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/Library/Python/2.7/site-packages/tensorflow/python/__init__.py", line 48, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import
我关注了official install pege,并输入了这两个命令
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl
$ sudo pip install --upgrade $TF_BINARY_URL
我已尝试卸载tensorflow
和protobuf
,然后重新安装tensorflow
,但它也犯了同样的错误。
在我卸载numpy
和tensorflow
后,我重新安装了numpy
。但是,我无法重新安装tensorflow
。
它扔了这个
$sudo pip install --upgrade $TF_BINARY_URL
The directory '/Users/Coda/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/Coda/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.
You must give at least one requirement to install (see "pip help install")
这是因为我错误地卸载了tensorflow
吗?
我使用pip uninstall tensorflow
卸载。
答案 0 :(得分:1)
我认为问题是您的numpy
是一个比需要更早的版本(0x9
= 9; 0xa
= 10)。也许升级numpy并查看导入tensorflow
之后是否有效。
编辑/更新:对于新的错误,请尝试使用--no-cache-dir
选项进行点击安装。