Using Google App Engine SDK with Python 2.7 on Mac

2020-05-20 08:37发布

问题:

I need to run Python 2.7 on my Mac Snow Leopard, which has Python 2.6 installed. According to this answer, running the Python 2.7 mpkg installer from Python.org should get me there.

The reason I need to do this is that I'm trying to run the Google App Engine SDK for the Python 2.7 runtime.

After installing Python 2.7, I'm still getting the following warning in my GAE server log:

Warning: You are using a Python runtime (2.6) that is older than the production runtime environment (2.7).

What else must I do to get the GAE SDK to recognize the new Python version?

EDIT 2:

Running:

$ sudo find / -name python2.7

I get:

/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/usr/local/bin/python2.7

According to the answers I went into GoogleAppLauncher -> Preferences and set the Python path to each of these, and each time I get the exact same error.

Running dev_appserver with the following flags: --admin_console_server= --port=8081 Python command: /Library/Frameworks/Python.framework/Versions/2.7 2011-11-14 16:12:24.726 GoogleAppEngineLauncher[57590:203] *** NSTask: Task create for path '/Library/Frameworks/Python.framework/Versions/2.7' failed: 22, "Invalid argument". Terminating temporary process.

Another Wierd thing is, it always tries to resolve to the same path, no matter which of those I plug in; It always reverts to /Library/Frameworks/Python.framework/Versions/2.7

EDIT 3:

OK, after entering the paths into the prefs field repeatedly, I finally just cleared it out, and somehow it's now pointing to the right place:

Running dev_appserver with the following flags:
    --admin_console_server= --port=8081
Python command: /usr/local/bin/python2.7

回答1:

Open the GAE launcher preferences and set the Python Path option to the fresh installed Python 2.7, in your case /usr/local/bin/python2.7 .



回答2:

Came across this question looking for a solution to the same dilemma regarding Mac, GAE and Python.

One comment I would like to make regarding setting the Python path using GAE Preferences. I notice you mention that you had a problem setting the Python path using the Preferences. I discovered that after editing the path, you have to press Enter. Otherwise, the path doesn't get updated. This might explain the weirdness you were mentioning when trying to edit the path field.



回答3:

I installed python 2.7.x from macports. I see this:

$ python --version
Python 2.7.2

$ which python
/opt/local/bin/python

So, in the preferences for GoogleAppEngineLauncher.app I set the python path to:

/opt/local/bin/python

In the console log, I see this:

*** Running dev_appserver with the following flags:
    --admin_console_server= --port=8081
Python command: /opt/local/bin/python

I still see some errors about libraries, in particular Can't open zipfile...setuptools but simple stuff at least seems to work.

Good luck!



回答4:

I am not sure if it helps, but instead of using the binaries from Python, I used MacPorts http://www.macports.org/ and installed the Python 2.7 runtime:

sudo port install python27