Ubuntu安装Python

原文链接

Ubuntu安装Python的方式与其他Linux系统有所不同,在这里介绍一下。

配置环境

切换的国内源:

sudo gedit /etc/apt/sources.list

将原有的源注释掉,添加如下内容:

#清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

更新apt-get

sudo apt-get update

安装build-essential

sudo apt-get install build-essential

安装Python

安装Python3.8:

sudo apt-get install python3.8
sudo apt install python3-pip

查看是否成功:

查看Python是否安装成功:

python3 --version

输出版本号Python 3.8.5即表示安装成功。

Ubuntu更换源

临时更换

使用阿里源:

pip install *** -i https://mirrors.aliyun.com/pypi/simple/ 

永久更换

新建.pip隐藏文件夹:

cd ~ 
mkdir .pip

新建pip.conf文件:

cd .pip
touch pip.conf 

用vim编辑pip.conf文件

vim pip.conf 

内容如下:

[global]
index-url = https://mirrors.aliyun.com/pypi/simple
[install]
trusted-host=mirrors.aliyun.com

 
 

学习更多编程知识,请关注:代码的路

 
 

你可能感兴趣的:(Ubuntu安装Python)