如何更改默认的python版本? [英] how to change default python version?

查看:835
本文介绍了如何更改默认的python版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Mac中安装了python 3.2.运行/Applications/Python 3.2/Update Shell Profile.command 后,令人困惑的是,当我在终端中键入 python -V 时,它表示 Python 2.6.1 ,如何更改默认的python版本?

I have installed python 3.2 in my mac. After I run /Applications/Python 3.2/Update Shell Profile.command, it's confusing that when I type python -V in Terminal it says that Python 2.6.1, how can I change the default python version?

推荐答案

这可能是向后兼容的理想选择.

This is probably desirable for backwards compatibility.

Python3破坏了向后兼容性,并且调用"python"的程序可能希望使用python2.您可能有很多程序和脚本,甚至都不知道哪个期望使用python = python2,并且更改此设置将破坏这些程序和脚本.

Python3 breaks backwards compatibility, and programs invoking 'python' probably expect python2. You probably have many programs and scripts which you are not even aware of which expect python=python2, and changing this would break those programs and scripts.

您可能正在寻找的答案是您不应更改此.

The answer you are probably looking for is You should not change this.

但是,您可以在shell中创建自定义别名.这样做的方式取决于shell,但也许可以执行alias py=python3

You could, however, make a custom alias in your shell. The way you do so depends on the shell, but perhaps you could do alias py=python3

如果您对如何启动最新版本的python感到困惑,则至少在Linux上python3使python2安装保持完整(由于上述兼容性原因);因此您可以使用python3命令启动python3.

If you are confused about how to start the latest version of python, it is at least the case on Linux that python3 leaves your python2 installation intact (due to the above compatibility reasons); thus you can start python3 with the python3 command.

这篇关于如何更改默认的python版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆