Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我怀疑我在Mac OS X 10.6.3上安装了多个版本的Python 2.6;如何设置应启动哪一个终端?_Python_Macos_Terminal - Fatal编程技术网

我怀疑我在Mac OS X 10.6.3上安装了多个版本的Python 2.6;如何设置应启动哪一个终端?

我怀疑我在Mac OS X 10.6.3上安装了多个版本的Python 2.6;如何设置应启动哪一个终端?,python,macos,terminal,Python,Macos,Terminal,当我在终端中输入python时,它会加载python 2.6.2。但是,在我的驱动器的不同位置有名为Python 2.6的文件夹。我不确定这是因为Python2.6安装在不同的地方,还是因为Python只是喜欢在不同的地方有很多文件夹 如果有多个安装,我可以设置应该使用哪个安装。在shell或命令提示符下运行python时,它将执行PATH环境变量中的第一个可执行文件 要找出正在执行的文件,请使用哪个python或python的位置。在shell或命令提示符下运行python时,它将执行PATH

当我在终端中输入python时,它会加载python 2.6.2。但是,在我的驱动器的不同位置有名为Python 2.6的文件夹。我不确定这是因为Python2.6安装在不同的地方,还是因为Python只是喜欢在不同的地方有很多文件夹

如果有多个安装,我可以设置应该使用哪个安装。

在shell或命令提示符下运行python时,它将执行PATH环境变量中的第一个可执行文件

要找出正在执行的文件,请使用哪个python或python的位置。

在shell或命令提示符下运行python时,它将执行PATH环境变量中找到的第一个可执行文件


要找出正在执行的文件,请使用哪个python或python所在的位置。

不要让它变得复杂。在~/.bash_别名中,假设您使用的是bash,请输入以下内容:

alias py26="/usr/bin/python-2.6.1"
alias py30="/usr/bin/python-3.0.0"
当然,我只是编了一些路径。输入适合您的系统的任何内容。如果~/.bash_别名文件不存在,请创建它


要使用它,只需在命令行中键入py26,并启动相应的解释器。

不要让它变得复杂。在~/.bash_别名中,假设您使用的是bash,请输入以下内容:

alias py26="/usr/bin/python-2.6.1"
alias py30="/usr/bin/python-3.0.0"
当然,我只是编了一些路径。输入适合您的系统的任何内容。如果~/.bash_别名文件不存在,请创建它


要使用它,只需在命令行中键入py26,并启动相应的解释器。

来自OS X Python手册页man Python:

 CHANGING THE DEFAULT PYTHON

 Using

       % defaults write com.apple.versioner.python Version 2.5

 will make version 2.5 the user default when running the both the python 
 and pythonw commands (versioner is the internal name of the version-
 selection software used).

 To set a system-wide default, replace `com.apple.versioner.python' with
 `/Library/Preferences/com.apple.versioner.python' (admin privileges will 
 be required).

 The environment variable VERSIONER_PYTHON_VERSION can also be used to 
 set the python and pythonw version:

       % export VERSIONER_PYTHON_VERSION=2.5 # Bourne-like shells
            or
       % setenv VERSIONER_PYTHON_VERSION 2.5 # C-like shells
       % python ...

 This environment variable takes precedence over the preference file
 settings.

从OS X Python手册页man Python:

 CHANGING THE DEFAULT PYTHON

 Using

       % defaults write com.apple.versioner.python Version 2.5

 will make version 2.5 the user default when running the both the python 
 and pythonw commands (versioner is the internal name of the version-
 selection software used).

 To set a system-wide default, replace `com.apple.versioner.python' with
 `/Library/Preferences/com.apple.versioner.python' (admin privileges will 
 be required).

 The environment variable VERSIONER_PYTHON_VERSION can also be used to 
 set the python and pythonw version:

       % export VERSIONER_PYTHON_VERSION=2.5 # Bourne-like shells
            or
       % setenv VERSIONER_PYTHON_VERSION 2.5 # C-like shells
       % python ...

 This environment variable takes precedence over the preference file
 settings.

非常感谢。我如何设置python来执行python的特定安装,而不是只执行它找到的第一个安装?@cojadate:就我现在所知,没有办法做到这一点。您可以做的是在PATH环境变量中找到版本正确的python可执行文件,然后生成一个名为python-2.5的可执行shell脚本,该脚本调用版本为2.5的可执行文件。谢谢!我如何设置python来执行python的特定安装,而不是只执行它找到的第一个安装?@cojadate:就我现在所知,没有办法做到这一点。您可以在PATH环境变量中找到版本正确的python可执行文件,然后生成一个名为python-2.5的可执行shell脚本,该脚本调用版本为2.5的可执行文件。