简体   繁体   English

在 ubuntu 上添加 python 3.10

[英]add python 3.10 on ubuntu

I'm just started using ubuntu and tried to upgrade python from 3.8.10 -> 3.10.4 in my venv with the following commands:我刚开始使用 ubuntu 并尝试使用以下命令在我的 venv 中将 python 从 3.8.10 -> 3.10.4 升级:

sudo apt update && sudo apt upgrade -y
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt install python3.10

it is installed successfully but when I check the version with:它安装成功但是当我检查版本时:

python3 --version

it still show:它仍然显示:

python 3.8.10 python 3.8.10

and my code can only work with python version > 3.10.我的代码只能使用 python 版本 > 3.10。 How can I fix this?我怎样才能解决这个问题?

I'm also using the deadsnakes PPA.我也在使用deadsnakes PPA。 Every version is installed separately, so you can switch versions on the fly.每个版本都是单独安装的,因此您可以即时切换版本。 So to use any version installed from deadsnakes, you have to call it explicitely.因此,要使用从 deadsnakes 安装的任何版本,您必须显式调用它。

$ python3.10 --version
Python 3.10.4

You have to use update-alternatives , following such approach https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux您必须使用update-alternatives ,遵循这种方法https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux

You'll be able to choose more conveniently which python version you want to use.您将能够更方便地选择要使用的 python 版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM