问题:(python中 import caffe)
1、 ImportError: No module named caffe
解决方法:
在每个python代码(或者每个python文件)前面加上如下代码,导入caffe路径。
import sys
sys.path.append("/home/xhh/caffe/python")
sys.path.append("/home/xhh/caffe/python/caffe")
问题:
2、RuntimeError: module compiled against APIversion 0xa but this version of numpy is 0x9
解决方法:
先在python环境下:
import numpy
printnumpy.__path__
找出numpy目录
然后执行下面即可(不用管numpy_old是否存在)
就解决了。
-----------------------------------------------------------------------------------------------------------------
原因我也搞不清楚。。。而且我还担心numpy改成了numpy_old之后后面运行程序有问题。
不过我觉得这个回答是挺中肯的,符合我的情况,但是不清楚怎么操作,难道重新安装么?因为我后来在python上安装了东西的,重新再来一遍好划不来啊。。所以暂且就按上面的方法来吧。
【
installing packet from file withrequirements may cause failures. I mean something like pip install –r requirements.txt
it seems to methat pip just installs packets in oreder without dependencies(first line from file,sencondline)
I had same issuebecause of having installed numpy out side of environment and numpy aftermatplotlib in requirements.txt Pip complied matplotlib with system nympy,afterthat it installed new numpy and nothing worked
i just haveswitched strings and set matplotlib after numpy now it works
】
问题:(python中 import cv2)
3、ImportError: No module named cv2
解决方法:
sudo apt-getinstall python-opencv
(小写python-opencv )
注:不能用pip安装方式(python-opencv),因为找不到源文件