1

I have the following code in appengine_config.py:

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

The output is as follows:

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

How is it possible that moves is a module when accessed through six, but can't be imported on its own?

To give some context about the environment:

  • I use a clean Debian GCE VM.

  • Install python 2.7, virtualenv, from within virtualenv install a short list of basic dependencies.

  • The script is run from within dev_appserver.py (Google App Engine standard environment local dev server)
  • six.moves imports fine from python shell
EvilTosha
  • 157
  • 11

1 Answers1

0

You've already imported six. That includes six.moves. So just use it as six.moves. To import just moves, use:

from six import moves
GAEfan
  • 11,244
  • 2
  • 17
  • 33
  • Well, the actual problematic line is `from six.moves import http_client` and I don't have control over that line. – EvilTosha Apr 17 '18 at 15:26
  • That's not what the error says. It says from line `import six.moves ImportError: No module named moves` – GAEfan Apr 17 '18 at 15:28
  • Sorry, I was not clear in the problem statement. I described the debug lines I have that cause the same behavior, but not the original problem. I will edit the question now. – EvilTosha Apr 17 '18 at 15:31