New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google App Engine ImportError: No module named msvcrt #594

Closed
dhstack opened this Issue Jun 9, 2016 · 4 comments

Comments

Projects
None yet
5 participants
@dhstack

dhstack commented Jun 9, 2016

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.

@dhstack

This comment has been minimized.

Show comment
Hide comment
@dhstack

dhstack commented Jun 9, 2016

Flask Issue:
pallets/flask#1901

@mitsuhiko

This comment has been minimized.

Show comment
Hide comment
@mitsuhiko

mitsuhiko Jun 9, 2016

Member

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

Member

mitsuhiko commented Jun 9, 2016

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

@untitaker untitaker added the bug label Jun 9, 2016

gwiskur added a commit to gwiskur/GAEStarterKit that referenced this issue Sep 10, 2016

Update appengine_config.py to fix Click bug
This will fix msvcrt import error in Click on the windows platform:
pallets/click#594

This fix is similar to the one used here:
gae-init/gae-init#527
@yassirSNS

This comment has been minimized.

Show comment
Hide comment
@yassirSNS

yassirSNS Sep 14, 2017

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

yassirSNS commented Sep 14, 2017

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

@pvlele

This comment has been minimized.

Show comment
Hide comment
@pvlele

pvlele Nov 7, 2017

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

pvlele commented Nov 7, 2017

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment