ubuntu 18.04 安装 python 3.7 及 安装python三方库 遇到的问题和解决思路

本文详细介绍如何在Linux环境下配置Python3.7仓库,安装虚拟环境venv,以及解决安装过程中可能遇到的错误,如'bdist_wheel'无效命令和Python.h文件缺失等问题。

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

# 配置仓库
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa

# 这里是安装 python3.7.5 之后, 需要安装三方库和包的情况, 解决安装 venv 不成功的问题:
sudo apt install python3.7 python3-venv python3.7-venv
python3.7 -m venv my_env_name

# 如果虚拟环境中安装三方库还会报其他错, 如:
# 1.报错: error: invalid command 'bdist_wheel'
# 解决:
pip install wheel

另外一个报错的解决:
`
  creating build/temp.linux-x86_64-3.7/MySQLdb
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 -I/usr/include/mysql -I/home/guang/Desktop/WorkSpace/sp-biz/sp-env/include -I/usr/include/python3.7m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.7/MySQLdb/_mysql.o
  MySQLdb/_mysql.c:37:10: fatal error: Python.h: No such file or directory
   #include "Python.h"
            ^~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for mysqlclient
`
# 解决思路
sudo apt-get install python3.7-dev default-libmysqlclient-dev
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值