Ubuntu安装Python

电子说

1.2w人已加入

描述

原文链接

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
trusted-host=mirrors.aliyun.com
trusted-host=mirrors.aliyun.com

学习更多编程知识,请关注我的公众号:

代码的路

Ubuntu

审核编辑 黄宇

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分