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
今天的文章ubuntu怎么安装python3.8_ubuntu安装python3.7「建议收藏」分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/79197.html