编译安装Python3.11
274
0
以debian11,python3.11.9为例:
#安装依赖
apt update
apt install -y wget build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev libnss3-dev
# 下载源代码
wget https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tar.xz -O Python-3.11.9.tar.xz
tar xvf Python-3.11.9.tar.xz
cd Python-3.11.9
#开启性能优化
./configure --enable-optimizations --with-lto
make 或者 make -j $(nproc)
make altinstall 或者 make install
#需要保留旧版本的用make altinstall
#验证
python3 -V
更新pip:
pip3 install --upgrade pip
1.临时换源:
#清华源
pip3 install markdown -i https://pypi.tuna.tsinghua.edu.cn/simple
# 阿里源
pip3 install markdown -i https://mirrors.aliyun.com/pypi/simple/
# 腾讯源
pip3 install markdown -i http://mirrors.cloud.tencent.com/pypi/simple
# 豆瓣源
pip3 install markdown -i http://pypi.douban.com/simple/
2.永久换源:
# 清华源
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# 阿里源
pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/
# 腾讯源
pip3 config set global.index-url http://mirrors.cloud.tencent.com/pypi/simple
# 豆瓣源
pip3 config set global.index-url http://pypi.douban.com/simple/#
如果pip安装出现警告,可设置(xxx替换为你用的Host,例如mirrors.aliyun.com)
pip3 config set install.trusted-host xxx