尝试使用 NDB 将 Google App Engine Python 2 应用程序迁移到 Cloud NDB Python 3 库时出现导入错误
Import Error when trying to migrate Google App Engine Python 2 app using NDB to the Cloud NDB Python 3 library
我目前正在着手 process 为 Python 3 迁移准备 App Engine 应用程序。
在第一步中:
- Migrate the App Engine bundled services in your Python 2 app to Google Cloud services ...
在所有 instructions 将数据存储模块从 google.appengine.ext.ndb
切换到 google.cloud.ndb
之后,我立即收到以下导入错误:
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
无论我是否在虚拟环境中进行测试,都会发生这种情况。导入 six.moves
在 python 控制台中工作。
显然这是捆绑测试服务器 dev_appserver.py
的问题。发现它已解决 here 由 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
我目前正在着手 process 为 Python 3 迁移准备 App Engine 应用程序。 在第一步中:
- Migrate the App Engine bundled services in your Python 2 app to Google Cloud services ...
在所有 instructions 将数据存储模块从 google.appengine.ext.ndb
切换到 google.cloud.ndb
之后,我立即收到以下导入错误:
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
无论我是否在虚拟环境中进行测试,都会发生这种情况。导入 six.moves
在 python 控制台中工作。
显然这是捆绑测试服务器 dev_appserver.py
的问题。发现它已解决 here 由 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