【发布时间】:2017-09-27 10:03:42
【问题描述】:
环境:
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卸载。
【问题讨论】:
-
当您尝试
import numpy时会发生什么? -
我可以完美导入
numpy。 -
您可能使用了错误版本的 TensorFlow。
-
我不确定需要安装哪个版本,但我安装了
tensorflow 0.9.0 -
最后,我安装了
virtualenv,它成功了。但我还是想弄清楚这个问题。
标签: python python-2.7 tensorflow