1、默認(rèn)python3、ipython3、pip的路徑
? ? name@host:~$ which python
? ? /usr/bin/python
? ? name@host:~$ which python3
? ? /usr/bin/python3
? ? name@host:~$ which pip
? ? /usr/local/bin/pip
? ? name@host:~$ which pip3
? ? /usr/local/bin/pip3
? ? name@host:~$ which ipython3
? ? /usr/local/bin/ipython3
? ? name@host:~$ which ipython
? ? /usr/local/bin/ipyth
2、安裝之后的路徑
? ? /usr/local/python3.7/bin/pip3
? ? /usr/local/python3.7/bin/pip3.7
? ? /usr/local/python3.7/bin/python3
? ? /usr/local/python3.7/bin/python3.7
? ??
3、編譯安裝python3.7
? ? 參考鏈接:https://ywnz.com/linuxjc/3159.html
? ? https://www.jianshu.com/p/7d32fba1121a
? ? 官網(wǎng)下載:https://www.python.org/downloads/ ?file中選擇 Gzipped source tarball
? ? 比如:壓縮包名字是Python-3.7.0.tgz
? ? 解壓:
? ? ? ? sudo tar -xzf Python-3.7.0.tgz
? ? ? ? 可以 -C /opt/ 指定解壓路徑
? ? 編譯
? ? ? ? cd Python-3.7.0
? ? ? ? ./configure --prefix=/usr/local/python3.6 --enable-optimization
? ? ? ? --prefix 是預(yù)期安裝目錄,
? ? ? ? --enable-optimizations
? ? ? ? 是優(yōu)化選項(xiàng)(LTO,PGO 等)加上這個(gè) flag 編譯后,性能有 10% 左右的優(yōu)化(如果沒(méi)記錯(cuò)的話),但是這會(huì)明顯的增加編譯時(shí)間。不過(guò)關(guān)于 LTO 和 PGO 其實(shí)不在今天文章的討論范圍內(nèi),建議感興趣的可以看看
? ? ? ? GCC 中 LTO 的具體實(shí)現(xiàn)https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html
? ? 安裝
? ? ? ? sudo make
? ? ? ? sudo make install
? ? 報(bào)錯(cuò)以及解決
? ? ? ? 1. ?configure: error:in ‘路徑名’:
? ? ? ? ? ? no acceptable C compiler found in $path
? ? ? ? ? ? 解決:
? ? ? ? ? ? sudo apt-get upgrade
? ? ? ? ? ? sudo apt-get install build-essential
? ? ? ? 2. ?Python build finished successfully!
? ? ? ? ? ? The necessary bits to build these optional modules were not found:
? ? ? ? ? ? _ctypes
? ? ? ? 3. ?zipimport.ZipImportError: can't decompress data; zlib not available
? ? ? ? ? ? 解決: sudo apt install zlib*
? ? ? ? ? ? 參考:https://blog.csdn.net/blueheart20/article/details/72827666
? ? ? ? 4. ?ModuleNotFoundError: No module named '_ctypes'
? ? ? ? ? ? Makefile:1130: recipe for target 'install' failed
? ? ? ? ? ? make: *** [install] Error 1
? ? ? ? ? ? 解決:
? ? ? ? ? ? 解決:安裝模塊
? ? ? ? ? ? sudo apt-get update
? ? ? ? ? ? sudo apt dist-upgrade
? ? ? ? ? ? sudo apt install build-essential libncursesw5-dev libgdbm-dev libc6-dev
? ? ? ? ? ? sudo apt install libssl-dev openssl
? ? ? ? ? ? sudo apt install libffi-dev
? ? ? ? ? ? ---------------------
? ? ? ? ? ? 原文:https://blog.csdn.net/wang725/article/details/79905612
? ? ? ? ? ? 參考鏈接:http://www.cnblogs.com/abeen/p/9355389.html
4、安裝完成
?
? ? The directory '/home/name/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
? ? The directory '/home/name/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
? ? Looking in links: /tmp/tmp4crntzmm
? ? Collecting setuptools
? ? Collecting pip
? ? Installing collected packages: setuptools, pip
? ? Successfully installed pip-19.0.3 setuptools-40.8.0
鏈接處理
? ? 建立軟連接:
? ? ? ? ln -s /usr/local/python3.7/bin/python3 ?/usr/bin/python3
? ? ? ? 這樣建立之后,pip3 也會(huì)自動(dòng)配置為python3.7的
? ? 下面的問(wèn)題出現(xiàn)后,將/usr/bin/python3有恢復(fù)成了原來(lái)的。
? ? ? ? 建立了python3.7的軟連接
? ? ? ? ? ? ln -s /usr/local/python3.7/bin/python3 ?/usr/bin/python3
? ? ? ? 建立了pip3.7的軟連接
? ? ? ? ? ? sudo ln -s ?/usr/local/python3.7/bin/pip3 ? ?/usr/local/bin/pip3.7
? ? 對(duì)于ipython3
? ? ? ? 1.查看到 ipython3 命令在是 /usr/local/bin/ipython3
? ? ? ? 2.cat /usr/local/bin/ipython3
? ? ? ? ? ? 內(nèi)容如下
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from IPython import start_ipython
if __name__ == '__main__':
? ? sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(start_ipython())
? ? ? ? ? ?復(fù)制一份命名為 /usr/local/bin/ipython3.7
? ? ? ? ? ?打開(kāi),將第一行改為 #!/usr/bin/python3.7
? ? ? ? ? ?試啟動(dòng):
? ? ? ? ? ? ? ? ipython3.7
? ? ? ? ? ? ? ? 報(bào)錯(cuò)
? ? ? ? ? ? ? ? ? ? Traceback (most recent call last):
? ? ? ? ? ? ? ? ? ? File "/usr/local/bin/ipython3.7", line 7, in
? ? ? ? ? ? ? ? ? ? from IPython import start_ipython
? ? ? ? ? ? ? ? ? ? ModuleNotFoundError: No module named 'IPython'
? ? ? ? ? ? ? ? 安裝 sudo pip3.7 search ?ipython
? ? ? ? ? ? ? ? 成功
ipython3.7
/usr/local/python3.7/lib/python3.7/site-packages/IPython/core/history.py:226: UserWarning: IPython History requires SQLite, your history will not be saved
warn("IPython History requires SQLite, your history will not be saved")
Python 3.7.3 (default, May 20 2019, 15:29:59)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.
? ? 這樣 python3.7 就是python3.7的了
? ? 這樣 pip3.7 就是python3.7的了
5、系統(tǒng)問(wèn)題:
? ? 1.執(zhí)行apt update 時(shí)報(bào)錯(cuò), 因?yàn)閜ython版本替換了
? ? ? ? 報(bào)錯(cuò)如下:
? ? ? ? ? ? name@host:~$ sudo apt update
? ? ? ? ? ? 命中:1 http://archive.ubuntukylin.com:10006/ubuntukylin xenial InRelease
? ? ? ? ? ? 命中:2 http://archive.canonical.com/ubuntu bionic InRelease
? ? ? ? ? ? 命中:3 http://mirrors.aliyun.com/ubuntu bionic InRelease
? ? ? ? ? ? 命中:4 http://mirrors.aliyun.com/ubuntu bionic-security InRelease
? ? ? ? ? ? 獲取:5 https://deb.opera.com/opera-stable stable InRelease [2,591 B]
? ? ? ? ? ? 已下載 2,591 B,耗時(shí) 2秒 (1,552 B/s)
? ? ? ? ? ? Traceback (most recent call last):
? ? ? ? ? ? File "/usr/lib/cnf-update-db", line 8, in
? ? ? ? ? ? from CommandNotFound.db.creator import DbCreator
? ? ? ? ? ? ModuleNotFoundError: No module named 'CommandNotFound'
? ? ? ? ? ? 正在讀取軟件包列表... 完成
? ? ? ? ? ? E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
? ? ? ? ? ? E: Sub-process returned an error code
? ? ? 同時(shí)ubuntu默認(rèn)終端打不開(kāi),還是因?yàn)閜ython的版本替換
? ? ? 解決:將/usr/bin/python3下的軟連接恢復(fù)成原來(lái)的。
? ? 2.出現(xiàn)問(wèn)題:
? ? ? ? E: 無(wú)法修正錯(cuò)誤,因?yàn)槟竽承┸浖3脂F(xiàn)狀,就是它們破壞了軟件包間的依賴(lài)關(guān)系。
? ? ? 原因:有 1 個(gè)軟件包沒(méi)有被完全安裝或卸載。
? ? ? 解決: sudo apt --fix-broken install
6、最后sudo apt autoremove清除多余的包
?
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
