Using python on OS X Lion
Ned Deily
nad at acm.org
Sun Dec 11 16:00:37 EST 2011
In article
<CAGZ55DT6XqbrDt-vwgcZsySTyZ=_QxHzPc8f=X0NMRs=fCtT=w at mail.gmail.com>,
Johann Spies <johann.spies at gmail.com> wrote:
> I have recently upgraded my Snow Leopard to Lion and now I am having all
> problems with python on my system e.g.:
>
> I have install PIL with easy_install but when I do
>
> import PIL
>
> Python cannot find the pil library. Installing psycopg2 in the same way was
> successful and I can use psycopg2 without a problem.
>
> Further, the new version of Python is 2.7.1 in Lion. But when I just run
> 'python' it calls up 2.6.5 - even after I have moved the application
> python2.6 to Trash.
>
> I see several guidelines for using python on OS X: some using macports,
> others homebrew and others 'pip' and 'virtualenv' . I come from a Linux
> background where a proper packaging system like apt (on Debian) prevent
> these types of problems.
>
> So my question: What is the recommended way of setting up a python
> environment in OS X?
>
> And how do I get rid of legacy python libraries on my system?
First, determine which python is being loaded. In OS X 10.7 (Lion),
Apple ships 2.7.1, 2.6.7, and 2.5.6 version of Python (all in /usr/bin)
so the 2.6.5 is coming from elsewhere. If you previously installed a
Python from a python.org installer, the framework will be in
/Library/Frameworks/Python.framework (and *not*
/System/Library/Frameworks, which is where Apple's Pythons are and
should not be modified). The python.org installers, by default, may
modify your shell profiles (i.e. .bash_profile, .profile, et al) to
prepend its framework bin directory to your shell PATH. Look for
something like this:
# Setting PATH for MacPython 2.6
# The orginal version is saved in .profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.6/bin:${PATH}"
export PATH
There are more details here http://bugs.python.org/issue7107
Also understand that if you use easy_install or pip, each Python
instance needs to have its own version of either one. Apple supplies
versions of easy_install in /usr/bin for its Pythons. If you install
another version of Python, you'll need to install another easy_install
and pip for it as well.
--
Ned Deily,
nad at acm.org
More information about the Python-list
mailing list