我第一天在 Ubuntu 上尝试使用 Python 编码时做了一些错误的事情,所以我重新安装了它。谁能告诉我在这里安装Python的最佳方法吗?我正在使用 Ubuntu 20.04,现在正在更新到 Ubuntu 23.10。
我懂了sudo apt install python3
?好吧,但这就是我的 Ubuntu 损坏的原因。谁能告诉我如何在不破坏任何程序的情况下安装完整的 python - 使用 python pip、venv 以及其他需要的东西。
有人问为什么我需要最新的python版本。我只是更喜欢它,但我想要任何Python 3(我更喜欢使用3.9和新的总是)。
我没有安装任何Python。我唯一做的就是sudo apt install python3-pip
python3-venv (和 python3.11-venv),venvs 无法安装,但为什么 VSCode 现在显示 4 个不同的 Python 解释器?我没有安装任何python版本。我从 ISO 文件安装了 Ubuntu 20.04,并升级到 23.10。Ubuntu 23.10 上的默认 Python 包是 python3.12。
显示 Python 解释器的 VSCode 图像:
ashish@ashish-pc:~$ pip3 --version
pip 23.1.2 from /usr/lib/python3/dist-packages/pip (python 3.11)
ashish@ashish-pc:~$ pip3 --version
pip 23.1.2 from /usr/lib/python3/dist-packages/pip (python 3.11)
ashish@ashish-pc:~$ sudo apt-get update && sudo apt-get install python3-venv
Hit:1 http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu mantic InRelease
Hit:2 http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu mantic-updates InRelease
Hit:3 http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu mantic-backports InRelease
Hit:4 http://mirrors.piconets.webwerks.in/ubuntu-mirror/ubuntu mantic-security InRelease
Hit:5 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:6 https://packages.microsoft.com/repos/code stable InRelease
Hit:7 http://archive.ubuntu.com/ubuntu mantic InRelease
Hit:8 http://archive.ubuntu.com/ubuntu mantic-updates InRelease
Hit:9 http://security.ubuntu.com/ubuntu mantic-security InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python3-venv : Depends: python3.11-venv (>= 3.11.2-1~) but it is not going to be installed
Depends: python3 (= 3.11.2-1) but 3.11.4-5 is to be installed
E: Unable to correct problems, you have held broken packages.
ashish@ashish-pc:~$ ^C
ashish@ashish-pc:~$
我用过sudo apt install python3-pip
它,效果很好,我得到了点。现在,当我尝试时,sudo apt install python3-venv
它生成了一条错误消息。我刚刚注意到该python -m venv
命令存在。