python-docs-samples icon indicating copy to clipboard operation
python-docs-samples copied to clipboard

ImportError: No module named msvcrt.

Open MasterOfOrigin opened this issue 9 years ago • 8 comments

In which file did you encounter the issue?

..../App-engine/standard/flask/tutorial/lib/click/__winconsole.py

Did you change the file? If so, how?

The lib folder and the click folder which contained this file was generated when I did "pip install -t lib -r requirements.txt " on the command prompt requirements.txt just contained one line that said Flask==0.12.2

These were the instructions

Describe the issue

I don't get any errors when I start the development server, it is only when I try to access localhost:8080 from my browser that the error occurs

MasterOfOrigin avatar Oct 25 '17 21:10 MasterOfOrigin

@andrewsg can you take a look here?

theacodes avatar Oct 25 '17 21:10 theacodes

Hi @mikemahon107, what behavior do you see when you try to access localhost:8080 from your browser? Do you get a stack trace at any point that you can share with us?

andrewsg avatar Oct 25 '17 21:10 andrewsg

Add this to appengine_config.py

import os import sys on_appengine = os.environ.get('SERVER_SOFTWARE','').startswith('Development')

if on_appengine and os.name == 'nt': sys.platform = "Not Windows"

pakyinchu avatar Jan 06 '18 03:01 pakyinchu

This issue is present for a while now. Happens when you try to kickstart a new Python+Flask application in the local development server on windows. Some guys here already did some research:

  • https://github.com/pallets/flask/issues/1901
  • https://github.com/pallets/click/issues/594

sorgloomer avatar Jan 16 '18 14:01 sorgloomer

I opened a ticket on App Engine's official issue tracker too: https://issuetracker.google.com/issues/72043776

The reason is that python's standard set of libraries is different on Windows and Linux. On Windows, the msvcrt module is present, and click is loading that module. App Engine's isolated environment strips some of the builtin modules too, leaving only the ones that are present on the Linux based cloud, that's why msvcrt seems to be missing.

sorgloomer avatar Jan 23 '18 11:01 sorgloomer

Thanks for being persistent and bringing this to our attention! msvcrt will be in the whitelist in the SDK once the change makes it through our testing pipeline.

myelin avatar Feb 10 '18 01:02 myelin

Issue addressed in comments above.

engelke avatar Dec 05 '18 17:12 engelke

This solution did not work for Django 1.11 :(

hassan-arrivy avatar Mar 15 '23 12:03 hassan-arrivy