问题

windows下使用gunicorn,运行Flask项目,报错

$ gunicorn --bind 127.0.0.1:8000 domain_admin.main:app

ModuleNotFoundError: No module named 'fcntl'

原因

看下​​官网​​的介绍:

Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for UNIX.

可以看到,它仅支持​​UNIX​​​, 不支持​​windows​

解决

我们可以使用​​waitress​​​来替换​​Gunicorn​

Waitress - A WSGI server for Python 2 and 3

文档

$ pip install waitress

$ waitress-serve --listen=127.0.0.1:8000 domain_admin.main:app

这样就可以正常启动了

参考
​​​https://stackoverflow.com/questions/45228395/error-no-module-named-fcntl​