windows10 操作系统;
gunicorn:20.1.0
在安装gunicorn之后,导入from gunicorn.app.wsgiapp import run报错。
pip 安装 gunicorn,如下:
C:\Users\Administrator>pip install gunicorn
Collecting gunicorn
Downloading gunicorn-20.1.0-py3-none-any.whl (79 kB)
---------------------------------------- 79.5/79.5 kB 1.5 MB/s eta 0:00:00
Requirement already satisfied: setuptools>=3.0 in e:\e01_pykaifa\e01_01_python3\install_python3.8.8\lib\site-packages (from gunicorn) (49.2.1)
Installing collected packages: gunicorn
Successfully installed gunicorn-20.1.0
C:\Users\Administrator>
导入from gunicorn.app.wsgiapp import run报错,如下:
C:\Users\Administrator>python
Python 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:18:16) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from gunicorn.app.wsgiapp import run
Traceback (most recent call last):
File "" , line 1, in <module>
File "E:\E01_PyKaiFa\E01_01_Python3\install_python3.8.8\lib\site-packages\gunicorn\app\wsgiapp.py", line 9, in <module>
from gunicorn.app.base import Application
File "E:\E01_PyKaiFa\E01_01_Python3\install_python3.8.8\lib\site-packages\gunicorn\app\base.py", line 11, in <module>
from gunicorn import util
File "E:\E01_PyKaiFa\E01_01_Python3\install_python3.8.8\lib\site-packages\gunicorn\util.py", line 8, in <module>
import fcntl
ModuleNotFoundError: No module named 'fcntl'
>>>
解决办法:在python路径下的Lib中新建一个fcntl.py文件内容如下:
# fcntl.py
LOCK_UN=8
F_GETFD=1
FD_CLOEXEC=1
F_SETFD=2
def fcntl(fd, op, arg=0):
return 0
def ioctl(fd, op, arg=0, mutable_flag=True):
if mutable_flag:
return 0
else:
return ""
def flock(fd, op):
return
def lockf(fd, operation, length=0, start=0, whence=0):
return
博主python安装目录:
E:\E01_PyKaiFa\E01_01_Python3\install_python3.8.8
这只解决了No module named ‘fcntl’,再次运行又会报新的错误:
C:\Users\Administrator>python
Python 3.8.8 (tags/v3.8.8:024d805, Feb 19 2021, 13:18:16) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from gunicorn.app.wsgiapp import run
Traceback (most recent call last):
File "" , line 1, in <module>
File "E:\E01_PyKaiFa\E01_01_Python3\install_python3.8.8\lib\site-packages\gunicorn\app\wsgiapp.py", line 9, in <module>
from gunicorn.app.base import Application
File "E:\E01_PyKaiFa\E01_01_Python3\install_python3.8.8\lib\site-packages\gunicorn\app\base.py", line 11, in <module>
from gunicorn import util
File "E:\E01_PyKaiFa\E01_01_Python3\install_python3.8.8\lib\site-packages\gunicorn\util.py", line 15, in <module>
import pwd
ModuleNotFoundError: No module named 'pwd'
>>>
为什么呢?
因为目前为止,Gunicorn还不能在Windows上运行。
但是已经有Windows支持的计划了,相信未来能很好的支持到Windows系统。
现在计划添加Windows支持。https://github.com/benoitc/gunicorn/issues/524
Gunicorn官网:
https://docs.gunicorn.org/en/stable/index.html