[Pythonmac-SIG] Python PyGame GTK SQLAlchemy on Leopard
Ned Deily
nad at acm.org
Sun Mar 22 20:23:54 CET 2009
In article
<5465ee790903220622m7897dfcch7e8d838e6b4292bc at mail.gmail.com>,
Chris Van Bael <chris.van.bael at gmail.com> wrote:
> some simple questions:
> - if I installed another Python, how can I start it? Whenever I open
> a terminal and type "python", I get Python 2.5.1, which I assume is
> the Python from Apple.
> - On Windows there is the directory /Lib/site-packages, I can't find
> this one on my Mac.
For python.org installers, each python major version lives in its own
framework sub-tree rooted at:
/Library/Frameworks/Python.framework/Versions/m.n/
where m.n is 2.5, 2.6, 3.0, etc.
At the top level of each version's subtree, there are bin, lib, include
and other directories. You'll find a pythonm.n executable and a python
symlink to it in the bin directory.
Site packages for each version reside within its subtree lib directory
but normally you don't need to manipulate those directly. By default,
distutils (and its users, easy_install, pip, virtualenv et al) will
install extensions to the right site-library by running under the
setup.py script or easy_install or pip under the appropriate version of
the python executable. Extension scripts will also be installed in the
corresponding bin directory.
So to select which python you want to start, you can invoke it directly
with:
/Library/Frameworks/Python.framework/Versions/2.5/bin/python
or modify your shell path to ensure that bin directory comes before
/usr/bin where the Apple-supplied python resides. Or create a shell
alias to it. Or use /usr/local/bin/pythonm.n because the python.org 2.x
installers create a link there by default - but beware because (1) that
doesn't help for installed scripts, (2) can be confusing with multiple
versions, and (3) by default the 3.x installers do not create that link.
For development environments with multiple versions, a good solution
these days is to use virtualenv. Jesse Noller has a very good overview
of how to do that here:
<http://jessenoller.com/2009/03/16/so-you-want-to-use-python-on-the-mac/>
Again, all of the above applies to python.org installers. For the
record, the Apple-supplied python uses a more elaborate framework
scheme, split between /System/Library/Frameworks and /Library/Python,
with different defaults. macports uses a framework scheme rooted at
/opt/local/Library/Frameworks. And fink python installs are more
debian-y style non-framework layouts in /sw/{bin,lib,...}.
--
Ned Deily,
nad at acm.org
More information about the Pythonmac-SIG
mailing list