1

我有以下代码appengine_config.py

...
import six
print six.__version__
print six.moves
import six.moves

输出如下:

1.11.0
<module 'six.moves' (built-in)>
ERROR    2018-04-17 10:51:19,875 wsgi.py:263] 
Traceback (most recent call last):
  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/api/lib_config.py", line 351, in __get
attr__
    self._update_configs()
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 287, in _update_configs
    self._registry.initialize()
  File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/api/lib_config.py", line 160, in initi
alize
    import_func(self._modname)
  File "/home/user/project/appengine_config.py", line 17, in <module>
    from six.moves import http_client
ImportError: No module named moves

通过 访问时怎么可能moves是一个模块six,但不能自行导入?

提供有关环境的一些上下文:

  • 我使用干净的 Debian GCE 虚拟机。

  • 从 virtualenv 中安装 python 2.7,virtualenv,安装基本依赖项的简短列表。

  • 该脚本从 dev_appserver.py(Google App Engine 标准环境本地开发服务器)中运行
  • six.moves从 python shell 导入罚款
4

1 回答 1

0

您已经导入了six. 这包括six.moves. 因此,只需将其用作six.moves. 要仅导入动作,请使用:

from six import moves
于 2018-04-17T13:59:09.847 回答