大家好,又见面了,我是你们的朋友全栈君。
Ubuntu安装Python3
(第0步)建议配置阿里镜像https://developer.aliyun.com/mirror/ubuntu
一、安装相关依赖
apt-get update && apt-get upgrade
apt-get install -y build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
apt-get dist-upgrade
apt-get install -y build-essential python-dev python-setuptools python-pip python-smbus
apt-get install -y build-essential libncursesw5-dev libgdbm-dev libc6-dev zlib1g-dev libsqlite3-dev tk-dev libssl-dev openssl libffi-dev wget
二、源码安装
# 下载链接
wget https://www.python.org/ftp/python/3.9.8/Python-3.9.8.tgz
# 解压
tar zxvf Python-3.9.8.tgz -C /usr/local
cd /usr/local/Python-3.9.8
# 配置
./configure prefix=/usr/local/python3 --enable-optimizations
# 编译
make && make install
三、配置系统环境
# 删除之前的python3
whereis python
#(有风险)* rm -rf 所有python3的版本(除去/usr/local/python3)
# 删除之前软连接
rm -rf /usr/bin/python
rm -rf /usr/bin/pip
# 添加新的链接
cp /usr/local/python3/lib/libpython3.9.a /usr/lib
echo "/usr/lib" > /etc/ld.so.conf.d/python3.9.conf
ldconfig
ln -s /usr/local/python3/bin/python3 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
# 添加环境变量
vi /etc/profile
#
# 添加 export PATH=$PATH:/usr/local/python3/bin
#
source /etc/profile
四、测试
python -V
pip -V
pip list
python -m pip install --upgrade pip
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/152407.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...