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

# 配置仓库
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

你可能感兴趣的:(系统,软件解决方案)