[英]Import caffe error
i compiled caffe successfully in my ubuntu machine but cannot import in python. 我在我的ubuntu机器上成功编译了caffe但是无法在python中导入。
Caffe is installed /home/pbu/Desktop/caffe Caffe安装/ home / pbu / Desktop / caffe
i tried adding the /home/pbu/caffe/python path to sys.path.append, still not working 我尝试将/ home / pbu / caffe / python路径添加到sys.path.append,仍然无法正常工作
i am trying to import caffe 我想进口咖啡
root@pbu-OptiPlex-740-Enhanced:/home/pbu/Desktop# python ./caffe/output.py
Traceback (most recent call last):
File "./caffe/output.py", line 13, in <module>
import caffe
File "/home/pbu/Desktop/caffe/python/caffe/__init__.py", line 1, in <module>
from .pycaffe import Net, SGDSolver
File "/home/pbu/Desktop/caffe/python/caffe/pycaffe.py", line 10, in <module>
from ._caffe import Net, SGDSolver
ImportError: No module named _caffe
This happens when you have not run make
for the python files separately. 如果你没有单独运行python文件的
make
,就会发生这种情况。
Run make pycaffe
soon after running make
in the Caffe directory. 在Caffe目录中运行
make
后立即运行make pycaffe
。
You may have to set the path to the python library correctly in Makefile.config
您可能必须在
Makefile.config
正确设置python库的路径
Adding to the above best answer. 添加到上面的最佳答案。 After you run
make
for python files by running make pycaffe
where you ran your previous make
s. 在运行
make
运行的Python文件make pycaffe
,你跑你以前的make
秒。 Then you have to export that python path by running export PYTHONPATH=<path-to-caffe>/python
. 然后你必须通过运行
export PYTHONPATH=<path-to-caffe>/python
导出该python路径。 You can choose to run this everytime before running a python code which utilizes caffe or add it to your ~/.bashrc
. 您可以选择在运行python代码之前每次运行此代码,该代码使用caffe或将其添加到
~/.bashrc
。
Well, I use the cmake-gui
for making
Caffe. 好吧,我用
cmake-gui
来making
Caffe。 There you need to set the Python paths to the Anaconda-python: 在那里你需要设置Anaconda-python的Python路径:
PYTHON_EXECUTABLE <path_to_anaconda_home>/bin/python2.7
PYTHON_INCLUDE_DIRECTORY <path_to_anaconda_home>/include/PYTHON2.7
PYTHON_LIBRARY <path_to_anaconda_home>/lib/libpython2.7.so
You should build caffe and pycaffe using the command: 你应该使用命令构建caffe和pycaffe:
cd $FRCN_ROOT/caffe-fast-rcnn
make -j8 && make pycaffe
and before the compilation, you should create a Makefile.config
file and set the corresponding library path, such as python. 在编译之前,您应该创建一个
Makefile.config
文件并设置相应的库路径,例如python。
More details are presented on the web: bgirshick/py-faster-rcnn . 更多细节见网站: bgirshick / py-faster-rcnn 。
What's more, when I run the "Beyond the demo" section, it seams that if I Create a symlink of the folder "VOCdevkit" as "VOCdevkit2007" which turns out to be "can't find the dataset". 更重要的是,当我运行“超越演示”部分时,如果我创建文件夹“VOCdevkit”的符号链接为“VOCdevkit2007”,结果是“无法找到数据集”。 So, I change the folder name as "VOCdevkit2007", and it runs well.
所以,我将文件夹名称更改为“VOCdevkit2007”,它运行良好。
I posted my Caffe install notes (my architecture: Arch Linux x86_64 | Intel i7 CPU ...) in an Anaconda Python 2.7 virtual environment here: 我在Anaconda Python 2.7虚拟环境中发布了我的Caffe安装说明(我的架构:Arch Linux x86_64 | Intel i7 CPU ...):
Caffe Installation Notes Caffe安装说明
https://gist.github.com/victoriastuart/fb2cb22209ccb2771963a25c06221213
I also encountered the (downstream) "Import caffe error," for which I needed to resolve my $PYTHONPATH to complete the make compilation and get Caffe finally installed, and also to be able to import it (in Python). 我还遇到了(下游)“导入caffe错误”,为此我需要解析我的$ PYTHONPATH以完成make编译并最终安装Caffe,并且还能够导入它(在Python中)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.