当前位置: 首页 > news >正文

解决caffe中的python环境安装的问题

由于caffe(GitHub - BVLC/caffe: Caffe: a fast open framework for deep learning.)使用的python版本是2.7,而非python3,所以安装的时候使用命令:sudo apt install python2.7进行安装。

而在安装python的各种包时,也不能用命令"sudo pip install 包名"安装,这样只会为python3安装相应的包。而应该用"sudo python -m pip install 包名",以安装wheel为例,使用命令"sudo python -m pip install wheel"进行安装。

如果你的linux系统中未安装pip,会报错"/usr/bin/python: No module named pip",这是因为python2.7对应的pip版本有要求。如何为Python 2.7中安装pip,可以参考这个链接(Python 2.7中安装pip_python2.7安装pip_dongzi321的博客-CSDN博客)

搞定pip的安装后,就可以进入到"/caffe/python"目录下,使用命令"sudo python -m pip install -r requirements.txt"安装一堆依赖包了。安装的过程中会遇到一个错误:提示找不到Python.h文件

    configure: creating ./config.statusconfig.status: creating _posixsubprocess_config.hbuilding '_posixsubprocess32' extensioncreating build/temp.linux-x86_64-2.7x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-W1mjrO/python2.7-2.7.18=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c _posixsubprocess.c -o build/temp.linux-x86_64-2.7/_posixsubprocess.o_posixsubprocess.c:16:10: fatal error: Python.h: 没有那个文件或目录16 | #include "Python.h"|          ^~~~~~~~~~compilation terminated.error: command 'x86_64-linux-gnu-gcc' failed with exit status 1----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-s937xK/subprocess32/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-PDa3Jr-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-s937xK/subprocess32/
You are using pip version 9.0.1, however version 23.2.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

这个问题是由于系统中未安装python2.7的开发包导致的,解决方法是使用命令"sudo apt install python2.7-dev"进行安装即可。

注意:不要按这种提示"You are using pip version 9.0.1, however version 23.2.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command."去升级pip,因为升级后就会与python2.7不匹配了。

http://www.lryc.cn/news/181816.html

相关文章:

  • 专业图像处理软件DxO PhotoLab 7 mac中文特点和功能
  • 面试题:Kafka 为什么会丢消息?
  • WSL安装异常:WslRegisterDistribution failed with error: 0xc03a001a
  • 【C语言 模拟实现strcmp函数】
  • maven 依赖版本冲突异常
  • 蓝牙核心规范(V5.4)11.5-LE Audio 笔记之Context Type
  • 【Linux】RPM包使用详解
  • 勒索病毒最新变种.Elbie勒索病毒来袭,如何恢复受感染的数据?
  • ArduPilot开源飞控之AP_Mission
  • JVM111
  • 排序篇(三)----交换排序
  • React antd Table点击下一页后selectedRows丢失之前页选择内容的问题
  • 蓝牙核心规范(V5.4)11.4-LE Audio 笔记之音频模型
  • Spring Boot:利用JPA进行数据库的查删
  • 1711: 【穷举】满足条件的整数
  • 【数据结构】堆的应用-----TopK问题
  • QT之xml文件的读写
  • C语言中的异常处理机制是什么?
  • Java中的并发编程模型和常用工具类
  • 第10章 MySQL(一)
  • 英飞凌 Tricore 架构中断系统详解
  • 单例模式:饿汉式
  • 什么是视图
  • C++——list(2)
  • Django基础讲解-路由控制器和视图(Django-02)
  • 【算法题】2873. 有序三元组中的最大值 I
  • HTML5 跨屏前端框架 Amaze UI
  • EXCEL会计记账报表财务软件企业公司做账系统凭证自动生成报表
  • Can‘t pickle <class ‘__main__.Test‘>: it‘s not the same object as __main__.Test
  • 第九章 动态规划 part14 1143. 最长公共子序列 1035. 不相交的线 53. 最大子序和