Ubuntu安裝Python

原文鏈接

Ubuntu安裝Python的方式與其他Linux系統(tǒng)有所不同,在這里介紹一下。

配置環(huán)境

切換的國內源:

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

?
?

學習更多編程知識,請關注:代碼的路

?
?

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容