关于 AttributeError: module ‘select’ has no attribute 'epoll’
关于该报错的情景先说一下,我是在Win环境下,导入的 ‘select’ 包 import select
然后在 主函数
中创建的 epoll
对象 epl = select.epoll()
在运行的时候 报错 内容如下:
AttributeError: module 'select' has no attribute 'epoll'
通过查看 select
源码发现,并没有 epoll
的模块,顿时纳闷儿,这是为啥呢?
没办法,自行百度吧,然而发现网上并没有太多的解释与对应的解决方法,最后在"炼数成金"找到了这样一段话,原文如下:
-
问:我在网上看到说epoll是在Linux2.6内核后才实现的,是否说明epoll不能在windows下跑起来呢?我找了个epoll的代码,在windows下报错,信息如下
Traceback (most recent call last): File "F:\firefox_download\workspace\myPy\server_epoll.py", line 16, in <module> READ_ONLY = ( select.EPOLLIN | select.EPOLLPRI | select.EPOLLHUP | select.EPOLLERR) AttributeError: 'module' object has no attribute 'EPOLLIN'
-
答:肯定不能啊,linux下的机制
-
答:这是Linux上的机制啊,想在Windows上用的话,可以用cygwin
* 这里的 “cygwin”具体什么意思,我也不清楚是啥,略显尴尬。 -
答:不能,epoll是liunx 2.6内核增加的新功能。
-
答:这是 linux 的机制,不能在 windows 下。
-
答:python官方文档介绍:
select.epoll([sizehint=-1]) (Only supported on Linux 2.5.44 and newer.) Returns an edge polling object, which can be used as Edge or Level Triggered interface for I/O events; see section Edge and Level Trigger Polling (epoll) Objects below for the methods supported by epolling objects.
-
仅仅支持Linux2.5.44或更高版本。
-
在windows下就没有办法了,装虚拟机吧。
-
-
答:装个centos或者ubuntu吧
-
答:这个确实是这样,之前我有在群里问过大家的,dir(select) windows和linux下结果都不一样