查看原文
其他

Ubuntu环境Python3版本的更新升级使用方法

哆啦安全 2022-07-23

安装Python3

sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev


Python3的下载地址

wget 'https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz'

tar zxvf Python-3.9.2.tgz

cd Python-3.9.2

sudo mkdir -p /usr/local/python3

./configure --prefix=/usr/local/python3  --enable-optimizations

make

sudo make install


sudo rm -rf /usr/bin/python3

sudo rm -rf /usr/bin/pip3


sudo ln -s /usr/local/python3/bin/python3.9 /usr/bin/python3

sudo ln -s /usr/local/python3/bin/pip3.9 /usr/bin/pip3


使用pip3安装时会报如下错误提示信息的解决方法

subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.


sudo find / -name lsb_release

sudo rm -rf /usr/bin/lsb_release


推荐使用virtuenv或者virtualenvwrapper创建虚拟环境去管理包,virtualenvwrapper使用还是很方便的,当然也可以直接使用pycharm去创建虚拟环境

pip3 install virtualenvwrapper


您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存