环境部署
2022/8/22原创大约 1 分钟约 353 字
1. 安装依赖包
#yum install readline-devel gcc make patch gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel ##必须安装否则会出现python3编译器中不能使用退格键和方向键
2. 下载安装包
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
3. 解压安装包
tar zvxf Python-3.6.1.tgz
4. 创建安装目录
mkdir /usr/local/python3
5. 安装命令
./configure --enable-shared --with-openssl=/usr/local/openssl
或者
./configure --with-openssl=/usr/include/openssl --prefix=/usr/local/python36 --enable-optimizations
make
make altinstall
6. 添加软链接
ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip
ln -s /usr/local/python3/bin/python3.8 /usr/bin/python
7. 临时禁用 SSL 验证
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org package_name
8. 使用 HTTP 镜像源
pip install -i <http://mirrors.aliyun.com/pypi/simple/> package_name
9. 创建虚拟环境
python -m venv venv
10. 虚拟环境使用
source activate
11. 错误处理
- python3: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory
# 查看动态链接库
ldd /usr/local/python36/bin/python3
# 复制文件
cp libpython3.6m.so.1.0 /usr/lib64/
- pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available ·pip install pyinstaller -i http://pypi.douban.com/simple --trusted-host pypi.douban.com`
- pip 限制 https
# 创建文件
vi ~/.pip/pip.conf
# 复制以下内容
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com
11.1. pip 安装时提示 ssl 错误,可以临时跳过
pip install --trusted-host mirrors.aliyun.com -i http://mirrors.aliyun.com/pypi/simple/ package_name
11.2. 安装缺少 ssl 模块
Modules/Setup 去掉注释这五行

./configure --with-ssl --prefix=/usr/local/python3.8
make && make install