【python初级】No module named ‘fcntl‘

【python初级】No module named 'fcntl'

1、背景

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 "<stdin>", 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'
>>>

2、解决办法

解决办法:在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

3、关于Gunicorn

这只解决了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 "<stdin>", 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
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jn10010537

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值