在Lion上为GAE配置Python
我刚接触Google App Engine(GAE),请多多包涵。
在尝试在本地设置一个简单的Python项目时,我遇到了一堆错误,提示GAE不支持Python 2.7。
我该如何配置GAE,让它指向我自定义的Python 2.5安装路径,也就是在/usr/local/python-2.5,而不是默认的系统版本(2.7,使用的是Lion系统)呢?
我的系统配置是:
OS: Mac OS 10.7
GoogleAppEngineLauncher: 1.5.2
当我尝试运行这个应用时,控制台显示的错误信息是:
*** Running dev_appserver with the following flags:
--admin_console_server= --port=8080
Python command: /usr/bin/python2.6
Warning: You are using a Python runtime (2.6) that is more recent than the production runtime environment (2.5). Your application may use features that are not available in the production environment and may not work correctly when deployed to production.
WARNING 2011-08-02 23:53:51,987 datastore_file_stub.py:511] Could not read datastore data from /var/folders/08/jlb1tb7s3hq1jhh9qzxfpqbw0000gn/T/dev_appserver.datastore
INFO 2011-08-02 23:53:51,989 rdbms_sqlite.py:58] Connecting to SQLite database '' with file '/var/folders/08/jlb1tb7s3hq1jhh9qzxfpqbw0000gn/T/dev_appserver.rdbms'
WARNING 2011-08-02 23:53:51,995 dev_appserver.py:4749] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO 2011-08-02 23:53:52,052 dev_appserver_multiprocess.py:637] Running application helloworld on port 8080: http://localhost:8080
INFO 2011-08-02 23:54:15,229 dev_appserver_main.py:667] Server interrupted by user, terminating
2 个回答
2
我发现使用GAE SDK和Python 2.7最简单的方法是先安装Mac port(http://www.macports.org/),然后通过它来安装Python 2.7。
安装好Mac port后:
$ sudo port install python27 # To install python 2.7
接着在Google App Engine启动器的菜单里,打开偏好设置,把/opt/local/bin/python2.7填入Python路径的框里。
比如要安装PIL或lxml,只需在命令行中输入以下命令:
# For PIL
$ sudo port install py27-pil
# For Lxml
$ sudo port install py27-lxml
1
在启动器里,点击 GoogleAppEngineLauncher -> Preferences
,然后在标记为 'Python Path' 的框里填入你的 Python 程序的路径。