如何设置终端默认的Python版本的OS X 10.6.8? [英] How to set default Python version in terminal on OS X 10.6.8?

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

问题描述

我刚刚在运行OS X 10.6.8的Mac上下载了python 2.7.安装的python的早期版本是2.6.

I just downloaded python 2.7 on my mac which runs OS X 10.6.8. The previous version of python installed was 2.6.

当我在终端中键入python时,它将打开python版本2.6.我要它打开python 2.7

When I type python in the terminal it opens python version 2.6. I want it to open python 2.7

如何默认使python 2.7打开?

How do I make Python 2.7 open by default?

推荐答案

默认情况下,OS X上适用于Python 2.x的python.org安装程序将shell配置文件(对于像bashcsh这样的标准shell)修改为将其框架bin目录添加到您的Shell路径的前面.假设您在安装过程中未取消选择该选项,则.bash_profile文件中现在应该包含以下内容.

The python.org installers for Python 2.x on OS X by default modify shell profiles (for the standard shells like bash and csh) to add its framework bin directory to the front of your shell path. Assuming you did not deselect the option during installation, there should now be the following in your .bash_profile file.

# Setting PATH for Python 2.7
# The orginal version is saved in .profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

但此配置文件仅由在启动一个新的终端窗口默认执行;它不适用于现有的终端会话.因此,请确保您打开一个新的,然后再试一次.如果您使用的是不同的外壳,你可能需要修改的shell启动做等价的.

But this profile is only executed by default when you launch a new terminal window; it won't apply to existing terminal sessions. So make sure you open a new one and then try again. If you are using a different shell, you may need to modify that shell's startup to do the equivalent.

默认情况下,OS X上适用于Python 3.x的python.org安装程序不会选择shell脚本修改选项.您可以在安装时启用它,也可以稍后在Applications文件夹中相应的Python x.x文件夹中运行Update Shell Profile.command文件.或者,您也可以手动编辑正确的配置文件.

The python.org installers for Python 3.x on OS X do not select the shell script modification option by default. You can enable it at installation or you can later run the Update Shell Profile.command file in the corresponding Python x.x folder in the Applications folder. Or you can just manually edit the right profile.

这篇关于如何设置终端默认的Python版本的OS X 10.6.8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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