Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use virtualenv with Google App Engine SDK on Mac OS X 10.6
    primarykey
    data
    text
    <p>I am pulling my hair out trying to figure this out because I had it working until last week and somehow it broke. </p> <p>When I setup a virtualenv for a Google App Engine app and start the app with <code>dev_appserver.py</code>, I get errors importing the standard library (like "ImportError: No module named base64").</p> <p>Here's what I'm doing:</p> <p>(Using the system Python)</p> <p><code>virtualenv --python=python2.5 --no-site-packages ~/.virtualenv/foobar</code></p> <p>Then I add the a <code>gae.pth</code> file to <code>~/.virtualenv/foobar/lib/python2.5/site-packages/</code> containing the Google App Engine libraries:</p> <pre><code>/usr/local/google_appengine /usr/local/google_appengine/lib/antlr3 /usr/local/google_appengine/lib/cacerts /usr/local/google_appengine/lib/django /usr/local/google_appengine/lib/fancy_urllib /usr/local/google_appengine/lib/ipaddr /usr/local/google_appengine/lib/webob_1_1_1 /usr/local/google_appengine/lib/yaml/lib </code></pre> <p>(That's based on <a href="https://stackoverflow.com/questions/2139693/unittest-import-error-with-virtualenv-google-app-engine-django/2450298#2450298">this answer</a>.)</p> <p>Then I source my "foobar" virtualenv and try to start my app with <code>dev_appserver.py</code>.</p> <p>The server starts but the first request errors out with the aforementioned "ImportError: No module named base64". If I visit the admin console I get "ImportError: No module named cgi".</p> <p>If I start up python, I can load these modules. </p> <pre><code>&gt;&gt;&gt; import base64 &gt;&gt;&gt; base64.__file__ '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/base64.py' </code></pre> <p>It seems that the SDK's sandboxing is preventing these libraries from getting loaded. But like I said, I had this working until last week...something changed or I inadvertently broke my virtualenv and I can't figure out how I got it working in the first place.</p> <p>Software versions:</p> <p>Google App Engine SDK 1.3.7<br> Mac OS X Snow Leopard 10.6.4<br> virtualenv 1.5.1</p> <p><strong>Update:</strong> In response to Alan Franzoni's questions:</p> <p>I am using the system Python that came with Mac OS X. I installed virtualenv via easy_install. I upgraded to virtualenv 1.5.1 today to try to fix the problem.</p> <p>If I run <code>python /usr/local/bin/dev_appserver.py</code> with the virtualenv python, the problem persists. If I deactivate the virtualenv and run that command with the system python2.5, it works. (Also, I can use the GoogleAppEngineLauncher to start my app.)</p> <p>Here is a full stack trace (this one uses the Kay framework, but the problem is the same with webapp):</p> <pre><code>Traceback (most recent call last): File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 3206, in _HandleRequest self._Dispatch(dispatcher, self.rfile, outfile, env_dict) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 3149, in _Dispatch base_env_dict=env_dict) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 525, in Dispatch base_env_dict=base_env_dict) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 2402, in Dispatch self._module_dict) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 2312, in ExecuteCGI reset_modules = exec_script(handler_path, cgi_path, hook) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 2208, in ExecuteOrImportScript exec module_code in script_module.__dict__ File "/Users/look/myapp/kay/main.py", line 17, in &lt;module&gt; kay.setup() File "/Users/look/myapp/kay/__init__.py", line 122, in setup from google.appengine.ext import db File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 1287, in Decorate return func(self, *args, **kwargs) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 1937, in load_module return self.FindAndLoadModule(submodule, fullname, search_path) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 1287, in Decorate return func(self, *args, **kwargs) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 1839, in FindAndLoadModule description) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 1287, in Decorate return func(self, *args, **kwargs) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py", line 1790, in LoadModuleRestricted description) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py", line 81, in &lt;module&gt; import base64 ImportError: No module named base64 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload