Skip to content

Google App Engine ImportError: No module named msvcrt #594

Closed

Description

@davidstackio

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.

Activity

  1. davidstackio commented on Jun 9, 2016

    @davidstackio
    Author

    Flask Issue:
    pallets/flask#1901

  2. mitsuhiko commented on Jun 9, 2016

    @mitsuhiko
    Contributor

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

  3. yassirasad commented on Sep 14, 2017

    @yassirasad

    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

  4. pvlele commented on Nov 7, 2017

    @pvlele

    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
  5. locked as resolved and limited conversation to collaborators on Nov 13, 2020
  6. added
    windows
    on Aug 8, 2026
  7. added this to the 7.0 milestone on Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

windows

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions