开发者

Python on OSX Setup Help for use with Google App Engine

When I type which python, I get the following result:

/Library/Frameworks/Python.framework/Versions/Current/bin/python

when I type "type -a python":

python is /Library/Frameworks/Python.framework/Versions/Current/bin/python python is /Library/Frameworks/Python.framework/Versions/2.6/bin/python python is /Library/Frameworks/Python.framework/Versions/2.7/bin/python python is /Library/Frameworks/Python.framework/Versions/Current/bin/python python is /usr/bin/python python is /usr/local/bin/python

I want to use python 2.5, which I have installed!

But at this point, I'm a bit confused, and I don't know how to set that as default, or what path I should be using.

Please note, I am developin开发者_StackOverflow社区g SPECIFICALLY for Google App Engine, so please keep that in mind.

Thanks in advance.


If you install Python 2.5 from python.org (specifically this dmg file), it can make a link for you into /usr/local/bin/python. Once you do that, and ensure /usr/local/bin is in your $PATH environment variable, then /usr/local/bin/python should be exactly what you want. To verify, try at a Terminal.app shell prompt...:

$ python -V
Python 2.5.4

this should confirm that 2.5.4 is the default Python. Also:

$ /usr/bin/env python -V

(since /usr/bin/env is what app engine is specifically using) should confirm the same result.

As an aside, it's very correct on your part to want to ensure you're using Python 2.5 for app engine purposes -- using 2.6 or 2.7 would give some occasional strange results, and, worse, would accept some code (using post-2.5 features) that then would not run on Google's app engine servers (which are using 2.5).


The easiest way I found to use GAE SDK is to install Mac port ( http://www.macports.org/ ) and from there the different version of python (2.5 and 2.7).

Once installed:

$ sudo port install python25  # To install python 2.5
$ sudo port install python27  # To install python 2.7

Then from Googleappenginelauncher menu, open Preferences and put /opt/local/bin/python2.5 or /opt/local/bin/python2.7 in the Python path field.

To install PIL or lxml for example just type these commands in a shell:

 # For PIL and python 2.7
 $ sudo port install py27-pil

 # For Lxml and python 2.7
 $ sudo port install py27-lxml
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜