caffe下安装python库

本文详细介绍了在Caffe环境下安装Python库的步骤,包括使用pip批量安装依赖、手动安装特定库如Cython,以及编译pycaffe和matcaffe。在安装过程中,针对可能出现的scipy安装问题和protobuf安装问题提供了解决方案,确保顺利完成Caffe的Python接口测试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、文件caffe-master/python/requirements.txt列举了Caffe依赖的python库,最简单的方法是用pip安装,pip的安装方法:

curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python get-pip.py
如果命令不能直接运行,则可以直接打开上面的网站链接,另存为 get-pip.py

然后开始用pip安装刚才的依赖吧:(在caffe-master目录下

sudo pip install -r python/requirements.txt
一般快捷安装是不能一下子安装好的,总会遇到这样那样的问题。

2、手动安装

下面是caffe-master/python/requirements.txt的内容(从上到下安装,有些库对上面的库有所依赖)

Cython>=0.19.2
numpy>=1.7.1
scipy>=0.13.2
scikit-image>=0.9.3
matplotlib>=1.3.1
ipython>=1.1.0
h5py>=2.2.0
leveldb>=0.191
networkx>=1.8.1
nose>=1.3.0
pandas>=0.12.0
python-dateutil>=1.4,<2
protobuf>=2.5.0
python-gflags>=2.0
pyyaml>=3.10
Pillow>=2.3.0

以 Cython 为例,手动的话用 sudo pip install Cython 即可,然后在 pip 的过程中有什么问题就相应解决。

3、在 caffe 目录下编译编译Python和Matlab用到的caffe文件

5、遇到的问题:

(1)install scipy  problem:

Command /usr/local/opt/python3/bin/python3.3 -c "import setuptools, tokenize;file='/private/tmp/pip_build_root/scipy/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-9r7808-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/tmp/pip_build_root/scipy Storing debug log for failure in /Users/dan/.pip/pip.log

解决方法:

sudo apt-get install python python-dev libatlas-base-dev gcc gfortran g++

(2)如果 pip 无法正常安装protobuf,则

使用 sudo apt-get install -y python-protobuf 完成对protobuf 的安装。


参考博客:

http://www.cnblogs.com/alfredtofu/p/3577241.html

http://stackoverflow.com/questions/22878109/error-installing-scipy-library-through-pip-on-python-3-compile-failed-with-err

http://blog.youkuaiyun.com/baobei0112/article/details/43083235(非常好的安装caffe的博客)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值