摘要
這解決了我的問題:
$ sudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
詳細
環境和症狀
我已經安裝在我的Mac OS X的優勝美地3條蟒蛇:
把隨我已經安裝了,我已經安裝了
- 3.4 OS
- 2.7
- 2.6
當然,我沒有在正確設置事情做得不好和蟒蛇的二進制文件和庫遍佈在Mac上的地方。
我試圖與https://github.com/Ning-Ding/Implementation-CVPR2015-CNN-for-ReID/tree/master/CUHK03
$ python ./main.py --dataset cuhk-03.h5
Using TensorFlow backend.
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
Traceback (most recent call last):
File "./main.py", line 14, in <module>
from model import generate_model,compile_model
File "/Users/rv186016/repositories/Implementation-CVPR2015-CNN-for-ReID/CUHK03/model.py", line 12, in <module>
from keras.layers import Input
File "/Library/Python/2.7/site-packages/keras/__init__.py", line 3, in <module>
from . import activations
File "/Library/Python/2.7/site-packages/keras/activations.py", line 4, in <module>
from . import backend as K
File "/Library/Python/2.7/site-packages/keras/backend/__init__.py", line 73, in <module>
from .tensorflow_backend import *
File "/Library/Python/2.7/site-packages/keras/backend/tensorflow_backend.py", line 1, in <module>
import tensorflow as tf
File "/Library/Python/2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Library/Python/2.7/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/Library/Python/2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
解決方案
上下工夫https://github.com/tensorflow/tensorflow/issues/559看着se7en007的評論後,當這個錯誤,我跑這些命令其愛我的問題。請參閱numpy
版本中的diff和rm
命令前後的路徑。
$ python
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 numpy
>>> numpy.__version__
'1.8.0rc1'
>>> numpy.__path__
['/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy']
>>> exit()
$ sudo rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
MUSRV186016-382:CUHK03 rv186016$ python
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 numpy
>>> numpy.__path__
['/Library/Python/2.7/site-packages/numpy']
>>> numpy.__version__
'1.12.0'
>>> ^D
$ python ./main.py --dataset cuhk-03.h5
Using TensorFlow backend.
____________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
====================================================================================================
input_1 (InputLayer) (None, 160, 60, 3) 0
____________________________________________________________________________________________________
input_2 (InputLayer) (None, 160, 60, 3) 0
____________________________________________________________________________________________________
conv2d_1 (Conv2D) (None, 156, 56, 20) 1520 input_1[0][0]
input_2[0][0]
...
試過'sudo pip install -U numpy'? – alvas
是的,它顯示Requirement已經是最新的:numpy in /Library/Python/2.7/site-packages –
你是否試過'sudo pip install numpy == 1.10.4'來獲取最新版本?還有一個標誌點,' - 升級'這可能有所幫助。 –