Make “python” run python3 at the prompt [duplicate]

。_饼干妹妹 提交于 2021-02-11 12:18:24

问题


I have two python installations..

python --> /Users/fraz/anaconda/bin/python (python2.7)

python3.7 --> /usr/local/bin/python3.7

Now.. I want reassign the commands. Such that python points to python3.7 --> /usr/local/bin/python3.7

and python2 points to python2.7 /Users/fraz/anaconda/bin/python

How do i do this reassignment?


回答1:


follow this question, modify your ~/.bashrc, add a new line:

alias python=python3.7

save and exit then open terminal, type

source ~/.bashrc

in my machine, typing python2 will open python 2.x by default. but if needed, you can add a new alias

alias python2=python2.7



回答2:


you can use softlink

ln -s /usr/bin/python /usr/local/bin/python3.7


来源:https://stackoverflow.com/questions/57368515/make-python-run-python3-at-the-prompt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!