[英]Import tensorflow error on mac
Enviorment : 环境 :
Mac OSX 10.10 Mac OSX 10.10
Python: 2.7.10 的Python:2.7.10
I have following error when I was trying to import tensorflow
尝试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
I was following the official install pege , and typed these two command 我正在遵循官方安装程序 ,并输入了这两个命令
$ 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
I've tried uninstall tensorflow
and protobuf
,and then reinstall tensorflow
, but it threw the same error. 我试过卸载tensorflow
和protobuf
,然后重新安装tensorflow
,但这引发了同样的错误。
After I uninstall numpy
and tensorflow
, I reinstall numpy
.However, I couldn't reinstall tensorflow
. 卸载numpy
和tensorflow
,我将重新安装numpy
但是无法重新安装tensorflow
。
It threw this 它扔了这个
$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")
Is that because I uninstall tensorflow
wrongly? 那是因为我错误地卸载了tensorflow
吗? I use pip uninstall tensorflow
to uninstall. 我使用pip uninstall tensorflow
进行卸载。
I think the issue is that your numpy
is one version older than needed ( 0x9
= 9; 0xa
= 10). 我认为问题在于您的numpy
版本比所需版本早( 0x9
= 9; 0xa
= 10)。 Maybe upgrade numpy and see if importing tensorflow
works after that. 也许升级numpy,然后查看导入tensorflow
是否tensorflow
。
Edit/Update: For your new error, try the pip install with the --no-cache-dir
option. 编辑/更新:对于新错误,请尝试使用--no-cache-dir
选项进行pip安装。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.