ubuntu 20使用python3.9并使用3.9的pip

1.下载python3.9

sudo apt-get install python3.9

2.切换

sudo su

输入下面指令

update-alternatives --list python

update-alternatives: error: no alternatives for python

出现以上所示的错误信息,则表示 Python 的替代版本尚未被update-alternatives 命令识别。想解决这个问题,我们需要更新一下替代列表,将python3.8 和 python3.9 放入其中。

# update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
update-alternatives: using /usr/bin/python3.8 to provide /usr/bin/python (python) in auto mode
# update-alternatives --install /usr/bin/python python /usr/bin/python3.9 2
update-alternatives: using /usr/bin/python3.9 to provide /usr/bin/python (python) in auto mode
```python
# update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
update-alternatives: using /usr/bin/python3.8 to provide /usr/bin/python3 (python3) in auto mode
# update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2
update-alternatives: using /usr/bin/python3.9 to provide /usr/bin/python3 (python3) in auto mode

再输入

python -v

在这里插入图片描述

python3 -V

在这里插入图片描述
到这里python切换完成

3.安装虚拟环境
1

sudo apt-get install python3.9-venv

python3 -m venv ~/bfvenv

cd ~/bfvenv
source ~/bfvenv/bin/activate
出现以及即代表完成

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值