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
?
?
學習更多編程知識,請關注:代碼的路
?
?