0.配置依賴環(huán)境,如果不進(jìn)行這步可能會(huì)出現(xiàn)一些問(wèn)題
中間可能有多余空格,去除下再運(yùn)行,一般都能安裝成功,如果不能可以先更新下sudo apt-get update
1
2
3
|
sudo apt - get install zlib1g - dev libbz2 - dev libssl - dev libncurses5 - dev libsqlite3 - dev libreadline - dev tk - dev libgdbm - dev libdb - dev libpcap - dev xz - utils libexpat1 - dev liblzma - dev libffi - dev libc6 - dev |
1.直接去官網(wǎng)下載你想的版本
2.解壓下載的包,在這之前你可以先mv你的包到指定位置解壓
1
|
jianjiacheng@j - computer:~$ tar zxvf python - 3.7 . 1 |
3.進(jìn)入解壓目錄
1
|
jianjiacheng@j - computer:~$ cd python - 3.7 . 1 / |
4.建立安裝的目錄
1
|
sudo mkdir - p / usr / local / python3 |
5.編譯安裝
執(zhí)行這步是后面最好加上 --enable-optimizations 會(huì)自動(dòng)安裝pip3及優(yōu)化配置
1
2
3
|
# ./configure --prefix=/usr/local/python3 --enable-optimizations # make # sudo make install |
6.刪除軟鏈接
先執(zhí)行查看版本,如果有則證明軟鏈接已存在,需要先刪去以前的再重新建立
1
2
3
4
5
6
|
/ / 這里表明我已有python3的軟鏈接而沒(méi)有pip3的軟鏈接所以需要?jiǎng)h除python3的軟鏈接重新建立 jianjiacheng@j - computer:~ / python - 3.7 . 1 $ python3 - v python 3.5 . 2 jianjiacheng@j - computer:~$ pip3 - v bash: / usr / lib / command - not - found: / usr / bin / python3: bad interpreter: no such file or directory |
1
2
|
rm - rf / usr / bin / python3 rm - rf / usr / bin / pip3 |
7.建立新的指向python3.7的軟鏈接
1
2
3
4
|
#添加python3的軟鏈接 ln - s / usr / local / python3 / bin / python3. 7 / usr / bin / python3 #添加 pip3 的軟鏈接 ln - s / usr / local / python3 / bin / pip3. 7 / usr / bin / pip3 |
8.檢測(cè)版本
1
2
3
4
|
jianjiacheng@j - computer:~$ python3 - v python 3.7 . 1 jianjiacheng@j - computer:~$ pip3 - v pip 10.0 . 1 from / usr / local / python3 / lib / python3. 7 / site - packages / pip (python 3.7 ) |
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。
原文鏈接:https://segmentfault.com/a/1190000018264955