'error when running flask - no module with name '_crypt'

i have a problem running flask. It started fine until I loaded a simple login form.

when running flask via gitbash, I get an error like this

flask run
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.

Error: While importing 'app', an ImportError was raised:

Traceback (most recent call last):
  File "C:\Users\****\AppData\Local\Programs\Python\Python39\lib\crypt.py", line 6, in <module>
    import _crypt
ModuleNotFoundError: No module named '_crypt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\****\AppData\Local\Programs\Python\Python39\lib\site-packages\flask\cli.py", line 234, in locate_app
    __import__(module_name)
  File "E:\Program Files\xampp\htdocs\****\app.py", line 2, in <module>
    from crypt import methods
  File "C:\Users\****\AppData\Local\Programs\Python\Python39\lib\crypt.py", line 9, in <module>
    raise ImportError("The crypt module is not supported on Windows")
ImportError: The crypt module is not supported on Windows

btw, i used windows



Solution 1:[1]

remove this from the top of the file:

from crypt import methods 

it should work again. At least it did for me. VSCode may have autogenerated this for you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tristan Isfeld