ubuntu 安装python3.10和对应版本的pip

装的时候运行了一个apt autoremove python3.6 直接搞崩了系统上不了网了,直接重装了系统,还是要小心啊。
sudo apt-get install --reinstall ubuntu-desktop

1. 安装python3.10 及 对应的pip

需要注意的是如果直接apt-get install python3-pip的话装的不是对应的3.10版本的,可能会导致多个问题。

1.1安装通用软件依赖

sudo apt install software-properties-common

1.2 添加Ubuntu的python版本 所在的库:

sudo add-apt-repository ppa:deadsnakes/ppa

执行后看一下输出,输出会告诉我们需要做什么:

ltt@ltt-E440:~$ sudo add-apt-repository ppa:deadsnakes/ppa
 This PPA contains more recent Python versions packaged for Ubuntu.

Disclaimer: there's no guarantee of timely updates in case of security problems or other issues. If you want to use them in a security-or-otherwise-critical environment (say, on a production server), you do so at your own risk.

Update Note
===========
Please use this repository instead of ppa:fkrull/deadsnakes.

Reporting Issues
================

Issues can be reported in the master issue tracker at:
https://github.com/deadsnakes/issues/issues

Supported Ubuntu and Python Versions
====================================

- Ubuntu 18.04 (bionic) Python2.3 - Python 2.6, Python 3.1 - Python 3.5, Python3.7 - Python3.11
- Ubuntu 20.04 (focal) Python3.5 - Python3.7, Python3.9 - Python3.11
- Note: Python2.7 (all), Python 3.6 (bionic), Python 3.8 (focal) are not provided by deadsnakes as upstream ubuntu provides those packages.
- Note: for focal, older python versions require libssl1.0.x so they are not currently built

The packages may also work on other versions of Ubuntu or Debian, but that is not tested or supported.

Packages
========

The packages provided here are loosely based on the debian upstream packages with some modifications to make them more usable as non-default pythons and on ubuntu.  As such, the packages follow debian's patterns and often do not include a full python distribution with just `apt install python#.#`.  Here is a list of packages that may be useful along with the default install:

- `python#.#-dev`: includes development headers for building C extensions
- `python#.#-venv`: provides the standard library `venv` module
- `python#.#-distutils`: provides the standard library `distutils` module
- `python#.#-lib2to3`: provides the `2to3-#.#` utility as well as the standard library `lib2to3` module
- `python#.#-gdbm`: provides the standard library `dbm.gnu` module
- `python#.#-tk`: provides the standard library `tkinter` module

可以看到输出告诉了我们系统支持的python版本,最后一个区间是python3.7到python3.11,我官网看的明明最新是3.10.4,所以我们装的是python3.10

  • 7
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
安装Python 3.10的方法有两种:直接使用apt-get安装和从官网下载安装。首先,可以尝试使用apt-get命令进行安装,但是可能会失败。另一种方法是从Python官网下载源文件进行安装。 直接使用apt-get安装Python 3.10未成功的话,可以尝试从官网下载源文件进行安装。具体步骤如下: 1. 安装依赖:在终端中运行命令`sudo apt-get update`更新软件包列表,然后运行`sudo apt-get install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev`安装所需依赖。 2. 从Python官网下载Python 3.10的源文件:在终端中运行命令`wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz`下载源文件。 3. 解压缩Python 3.10源文件:运行命令`tar -xf Python-3.10.0.tgz`解压缩源文件。 4. 开始安装:进入解压缩后的文件夹,运行命令`cd Python-3.10.0`,然后运行`./configure`进行配置。 5. 编译:运行命令`make`进行编译。如果没有安装make,可以运行`sudo apt-get install make`进行安装。 6. 安装:运行命令`sudo make install`进行安装。 更新Python默认指向Python 3.10有两种方法:建立软连接和设置Python的环境变量。 建立软连接的方法如下: 1. 找到Python 3.10安装路径:可以在终端中运行`which python3`命令找到Python 3.10安装路径,例如`/usr/local/bin/python3`。 2. 建立软连接:运行命令`sudo ln -s /usr/local/bin/python3 /usr/bin/python3`建立软连接。 设置Python的环境变量的方法如下: 1. 打开bashrc文件:在终端中运行命令`vim ~/.bashrc`打开bashrc文件。 2. 添加环境变量:在文件的最后一行添加以下内容:`export PATH="/usr/local/bin:$PATH"`。 3. 保存并退出:按下Esc键,输入`:wq`保存并退出vim编辑器。 更新pip默认指向Python 3.10可以通过以下步骤完成: 1. 找到Python 3的安装路径,可以运行`which python3`命令找到路径,例如`/usr/local/bin/python3`。 2. 更新pip的默认指向:运行命令`sudo ln -s /usr/local/bin/pip3 /usr/local/bin/pip`更新pip的默认指向。 回答完问题后的
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值