I suspect I have multiple version of Python 2.6 installed on Mac OS X 10.6.3; how do I set which one Terminal should launch?
When I enter in python in Terminal it loads up Python 2.6.2. However there are folders by the name of Python 2.6 in different places on my drive. I'm not sure if that's because Python 2.6 has been installed in different places or because Python just likes to 开发者_运维知识库have lots of folers in different places.
If there are multiple installations, I could really do with being able to set which one should be used.
When you run python in a shell or command prompt it will execute the first executable file which is found in your PATH environment variable.
To find out what file is being executed use which python or where python.
Don't make it complicated. In your ~/.bash_aliases put the following (assuming you are using bash):
alias py26="/usr/bin/python-2.6.1"
alias py30="/usr/bin/python-3.0.0"
Of course, I just made up those paths. Put in whatever is correct for your system. If the ~/.bash_aliases file does not exist, create it.
To use it just type, at the command line, py26 and the appropriate interpreter starts up.
From the OS X Python man page (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.
加载中,请稍侯......
精彩评论