[英]How do I set the most recent Python installation as default version?
我通過以下方式在我的(LinuxMint)計算機上安裝了 Python 3.5:
sudo apt-get install python3.5
但是,當我運行 python -V 時,它顯示正在使用 Python 2.7。
如何告訴系統使用更新版本的 Python?
你已經安裝了 python2.7 並且你已經有了一個指向python2.7
可執行文件的鏈接,這樣當你簡單地運行python
,它實際上運行python2.7
。 當您安裝 python3.5 時,該鏈接仍然存在。
您應該運行python3
(或python3.5
),或者應該用這樣的新鏈接替換鏈接(假設 /usr/bin 中為 python3.5):
ln -sf /usr/bin/python3.5 /usr/bin/python
如果您無權創建鏈接並且您的用戶是 sudoer,請在命令前添加sudo
。
更動態,
ln -sf $(which python3) $(which python)
這會強制創建從 python3 到 python 的符號鏈接。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.