I am currently starting the process of preparing an App Engine app for Python 3 migration. During the first step:
- Migrate the App Engine bundled services in your Python 2 app to Google Cloud services ...
Following all the instructions to switch the datastore module from google.appengine.ext.ndb
to google.cloud.ndb
, I immediately get the following Import Error:
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 311, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/home/---.py", line 8, in <module>
from google.cloud import ndb
File "/home/test_env/local/lib/python2.7/site-packages/google/cloud/ndb/__init__.py", line 28, in <module>
from google.cloud.ndb.client import Client
File "/home/test_env/local/lib/python2.7/site-packages/google/cloud/ndb/client.py", line 23, in <module>
from google.cloud import _helpers
File "/home/test_env/local/lib/python2.7/site-packages/google/cloud/_helpers.py", line 29, in <module>
from six.moves import http_client
ImportError: No module named moves
This happens whether or not I am testing in a virtual environment. Importing six.moves
works in a python console.
Apparently this is an issue with the bundled test server dev_appserver.py
. Found it solved here by Andrewsg:
I think we've identified an issue with devappserver related to the six library specifically. Could you please try a workaround? Add the line:
import six; reload(six)
to the top of your app, before NDB is loaded