sebastian-ardila / google-app-engine-django

Automatically exported from code.google.com/p/google-app-engine-django
Apache License 2.0
0 stars 0 forks source link

google-app-egine-django does not work when you have the python bindings for protobuf installed #96

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install the python bindings for protobuf
2. Follow the guide for using google-app-engine-django
3. run python manage.py runserver

What is the expected output? What do you see instead?
The dev_appserver should start up. Instead you get an error importing 'from
google.appengine.api import apiproxy_stub_map'

What version of the product are you using? On what operating system?
MacOsX 10.5 on r64 google-app-engine-django and 1.1.5 GAE SDK.

Please provide any additional information below.

The problem occurs because:

from google.appengine.api import apiproxy_stub_map

finds google in the system installed egg of the protobuf bindings
(google.protobuf...). I am not sure if this is a python import bug or not
but because of this python cannot find google.appengine.

A possible solution is to prepend /usr/local/google_appengine to sys.path
instead of appending it to avoid this lookup error (of course in that case
I believe you won't be able to load google.protobuf).

Original issue reported on code.google.com by evlogimenos on 12 Oct 2008 at 1:23

GoogleCodeExporter commented 9 years ago
I had the exact same problem:
1. Extract google-app-engine-django
2. Link google_appengine as .google_appengine in the project directory
3. run python manage.py.runserver fails with importError in
appengine_django/__init__.py on line 109: 'from google.appengine.api import
apiproxy_stub_map'

This is because when executing line 56: ' from google.appengine.api import
apiproxy_stub_map', although the import fails, the 'google' module remains 
cached in
sys.modules as some module added on PYTHONPATH by protobuf.
I got around this problem by removing the cached module after injecting
google.appengine packages in sys.path and reimporting:

===================================================================
--- appengine_django/__init__.py        (revision 66)
+++ appengine_django/__init__.py        (working copy)
@@ -106,6 +106,11 @@
   # must come first to allow the local imports to override the SDK and
   # site-packages directories.
   sys.path = sys.path[0:1] + EXTRA_PATHS + sys.path[1:]
+  if sys.modules.has_key('google'):
+      old_mod = sys.modules['google']
+      del sys.modules['google']
+      import google
+      google.__path__ += old_mod.__path__
   from google.appengine.api import apiproxy_stub_map

 # Look for a zipped copy of Django.
===================================================================

Original comment by dorin.scutarasu@gmail.com on 11 Jan 2009 at 5:42