Python如何在ubuntu中更改Python和pip指向
更新時間:2024年08月07日 14:40:30 作者:dream_uping
這篇文章主要介紹了Python如何在ubuntu中更改Python和pip指向問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
python在ubuntu更改Python和pip指向
系統(tǒng)自帶的python為python3,此次下載版本系統(tǒng)沒有安裝python2,并且終端輸入python提示找不到,輸入python3才行。
python版本為3.7.5
- 沒有自帶pip,需要手動安裝pip3,命令為
sudo apt-get install python3-pip
- 下面將“python”指向“python3”:
echo alias python=python3 >> ~/.bashrc source ~/.bashrc
- 下面將“pip”指向“pip3”:
echo alias pip=pip3 >> ~/.bashrc source ~/.bashrc
window修改python pip默認安裝位置
假設 python安裝目錄為D:/SDK/python,修改D:\SDK\python\Lib\site.py文件
找到USER_SITE和USER_BASE修改其值(原值是None),即是要保存的位置
# for distutils.commands.install # These values are initialized by the getuserbase() and getusersitepackages() # functions, through the main() function when Python starts. USER_SITE = "D:/SDK/python/Lib/site-packages" USER_BASE = "D:/SDK/python/Scripts"
保存后,
使用 python -m site 命令查看:
立即生效?。。?!
總結
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。