How to make python3.2 interpreter the default interpreter in debian

独自空忆成欢 提交于 2019-12-31 19:14:13

问题


I got both python2 and python3 installed in my debian machine. But when i try to invoke the python interpreter by just typing 'python' in bash, python2 pops up and not python3. Since I am working with the latter at the moment, It would be easier to invoke python3 by just typing python. Please guide me through this.


回答1:


the only somehow safe way would be to use an alias in your shell, by placing

alias python=python3

into your ~/.profile or ~/.bashrc...

this way the system scripts depending on python being python2 won't be affected.




回答2:


Well, you can simply create a virtualenv with the python3.x using this command:

virtualenv -p <path-to-python3.x> <virtualenvname>




回答3:


btw, if you are using bash or running from the shell, and you normally include at the top of the file the following line:

#!/usr/bin/python

then you can change the line to instead be:

#!/usr/bin/python3

That is another way to have pythonX run instead of the default (where X is 2 or 3).




回答4:


Others have adviced you about the possible drawbacks, so, on the issue at hand:

ln -s $(which python3) /usr/local/bin/python



回答5:


using command:

    update-alternatives --config python

Might Work However On My System(I have Python2&3 Installed As Well) It Gives Me An Error Saying No Alternatives For Python...



来源:https://stackoverflow.com/questions/10434260/how-to-make-python3-2-interpreter-the-default-interpreter-in-debian

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