Click: Google App Engine ImportError: No module named msvcrt

Created on 9 Jun 2016  路  4Comments  路  Source: pallets/click

Because Click was added to Flask 0.11 for the New Command Line Interface, and Click imports the Windows only module msvcrt, and the Google App Engine local development server doesn't contain this module, an import error is thrown.

image

I've created a workaround for the gae-init project (by modifying the App Engine config file), but it would be best to have a fix come directly from Flask/Click since there are likely many more people who will experience this issue when using Flask 0.11 with Google App Engine.

bug

Most helpful comment

Oh man. GAE keeps annoying me :( I will see if i can fix this.

All 4 comments

Oh man. GAE keeps annoying me :( I will see if i can fix this.

I am facing same issue, it's annoying . I'm new to Flask on App Engine.

First dev_appserver.py app.yaml command was not running, it opens dev_appserver.py source code in editor. -> I changed associate file for .py to default python.exe, now working, but to open source code of .py file, now I have to right click and open with any editor (annoying).

Secondly it gives error dev_appserver: too few argumunets -> added /* in registry setting (No idea what it does). working now.

Now this Click thing. -.> installed Click 5.1 using pip, still issue is there.
raise ImportError('No module named %s' % fullname)
ImportError: No module named msvcrt

Change appengine_config.py

import os
import sys

if os.environ.get('SERVER_SOFTWARE', '').startswith('Google App Engine'):
  sys.path.insert(0, 'lib.zip')
else:
  if os.name == 'nt':
    os.name = None
    sys.platform = ''

  import re
 # from google.appengine.tools.devappserver2.python import stubs
  from google.appengine.tools.devappserver2.python.runtime import stubs

  re_ = stubs.FakeFile._skip_files.pattern.replace('|^lib/.*', '')
  re_ = re.compile(re_)
  stubs.FakeFile._skip_files = re_
  sys.path.insert(0, 'lib')
sys.path.insert(0, 'libx')


def webapp_add_wsgi_middleware(app):
  from google.appengine.ext.appstats import recording
  app = recording.appstats_wsgi_middleware(app)
  return app
Was this page helpful?
0 / 5 - 0 ratings

Related issues

georgexsh picture georgexsh  路  13Comments

flying-sheep picture flying-sheep  路  34Comments

omribahumi picture omribahumi  路  14Comments

gibiansky picture gibiansky  路  12Comments

mahmoudimus picture mahmoudimus  路  25Comments