簡體   English   中英

在linux中如何設置Python以便在使用python時它將使用python3而不是python 2.7

[英]In linux how to set Python so that when using python it will use python3 and not python 2.7

當我輸入 python --version 時,它給出了 python --version 我希望默認行為使用 python3。 每次創建運行python時,我都不必鍵入“python3”。 在 linux hwo 中我會改變這個嗎?

在您的~/.bash_profile ,添加以下內容:

export PATH=/Users/reblochonmasque/anaconda3/envs/py38/bin/:$PATH
alias python3=/Users/reblochonmasque/anaconda3/envs/py38/bin/python
alias python=/Users/reblochonmasque/anaconda3/envs/py38/bin/python

export PATH=/Users/reblochonmasque/anaconda3/envs/py2k/bin/:$PATH
alias python2=/Users/reblochonmasque/anaconda3/envs/py2k/bin/python

PATH替換為系統上 python 安裝的路徑; 那將是這樣的

export PATH=/usr/local/bin:$PATH

別名允許您在命令行中使用pythonpython3啟動 python3 ,以及使用python2

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM