0

i have a django project that runs on ubuntu 20.04 version. i use selenium versio 4.1.5 . the selenium package has the trio package as a dependecy (version 0.22.2). until i added pymongo version (4.4.1) to my project everything worked fine. when installing it i get the following error :

Traceback (most recent call last):
    File "mypath/checknet-api/./manage.py", line 26, in <module>
       execute_from_command_line(sys.argv)
    File "mypath/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 381,in execute_from_command_line
        utility.execute()
    File "mypath/venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 357, in execute
    django.setup()
    File "mypath/venv/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
    File "mypath/venv/lib/python3.9/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
    File "mypath/<innerpath>/apps.py", line 8, in ready
    import checknet.main.signals
    File "mypath/<innerpath>//signals.py", line 6, in <module>
    from .tasks import execute
       File "mypath/<innerpath>/tasks.py", line 7, in <module>
    from .bots import (
    File "mypath/<innerpath>/fbi_crawler.py", line 2, in <module>
       from pymongo import MongoClient
    File "/mypath/venv/lib/python3.9/site-packages/pymongo/__init__.py", line 92, in <module>
       from pymongo.mongo_client import MongoClient
    File "mypath/venv/lib/python3.9/site-packages/pymongo/mongo_client.py", line 61, in <module>
    from pymongo import (
    File "mypath/venv/lib/python3.9/site-packages/pymongo/uri_parser.py", line 32, in <module>
    from pymongo.srv_resolver import _HAVE_DNSPYTHON, _SrvResolver
    File "mypath/venv/lib/python3.9/site-packages/pymongo/srv_resolver.py", line 21, in <module>
    from dns import resolver
    File "mypath/venv/lib/python3.9/site-packages/dns/resolver.py", line 30, in <module>
    import dns._ddr
    File "mypath/venv/lib/python3.9/site-packages/dns/_ddr.py", line 12, in <module>
    import dns.nameserver
    File "mypath/venv/lib/python3.9/site-packages/dns/nameserver.py", line 5, in <module>
    import dns.asyncquery
    File "mypath/venv/lib/python3.9/site-packages/dns/asyncquery.py", line 38, in <module>
    from dns.query import (
    File "mypath/venv/lib/python3.9/site-packages/dns/query.py", line 63, in <module>
    import httpcore
    File "mypath/venv/lib/python3.9/site-packages/httpcore/__init__.py", line 1, in <module>
    from ._api import request, stream
    File "mypath/venv/lib/python3.9/site-packages/httpcore/_api.py", line 5, in <module>
    from ._sync.connection_pool import ConnectionPool
    File "mypath/venv/lib/python3.9/site-packages/httpcore/_sync/__init__.py", line 1, in <module>
    from .connection import HTTPConnection
  File "mypath/venv/lib/python3.9/site-packages/httpcore/_sync/connection.py", line 12, in <module>
    from .._synchronization import Lock
  File "mypath/venv/lib/python3.9/site-packages/httpcore/_synchronization.py", line 13, in <module>
    import trio
  File "mypath/venv/lib/python3.9/site-packages/trio/__init__.py", line 19, in <module>
    from ._core import TASK_STATUS_IGNORED as TASK_STATUS_IGNORED  # isort: skip
  File "mypath/venv/lib/python3.9/site-packages/trio/_core/__init__.py", line 21, in <module>
    from ._local import RunVar
  File "mypath/venv/lib/python3.9/site-packages/trio/_core/_local.py", line 5, in <module>
    from . import _run
  File "mypath/venv/lib/python3.9/site-packages/trio/_core/_run.py", line 2543, in <module>
    from ._io_epoll import EpollIOManager as TheIOManager
  File "mypath/venv/lib/python3.9/site-packages/trio/_core/_io_epoll.py", line 189, in <module>
    class EpollIOManager:
  File "mypath/venv/lib/python3.9/site-packages/trio/_core/_io_epoll.py", line 190, in EpollIOManager
    _epoll = attr.ib(factory=select.epoll)
AttributeError: module 'select' has no attribute 'epoll'

I couldn't find anything about this problem anywhere. i think that is some kind of package mismatch because of the httpcore package (pymongo dependecy) that importing the trio package.

python version -> Python 3.9.7

i tried to install different version of the packages to check if there is a problem with specific versions . but couldn't find a solution

1 Answers1

0

So the odd thing here is that it's saying select.epoll doesn't exist. The select module is part of the standard library, and it should always have epoll if you're running on Linux. So it seems like your python install itself is broken somehow. Are you using ubuntu's python or did you get it somewhere else?

Nathaniel J. Smith
  • 11,613
  • 4
  • 41
  • 49
  • hey its the default ubuntu's python. the strange thing is that if open the python console with this interpreter and try to invoke select epoll it works fine. it only happen with the pymongo import like somehere in the way the select module is different from the standard library . if i import pymongo in the python console it doesnt gives error. its only the integration with the django project and the trio package that is installed by selenium – Eyal Bismuth Jul 24 '23 at 08:01
  • I guess at this point I'd try temporarily editing `mypath/venv/lib/python3.9/site-packages/trio/_core/_io_epoll.py` to print out `select.__file__` and see where this weird `select` is coming from. – Nathaniel J. Smith Jul 24 '23 at 09:22
  • i added select = eventlet.patcher.original('select') to the trio _io_epoll.py and it fixed the problem. when i run select.__file__ i got an error. i think there is implementation of select.py inside gevent library (which i use in my project) that removes some functionality like the epoll. select = eventlet.patcher.original('select') restore the default implementation. thanks for your help ! – Eyal Bismuth Jul 24 '23 at 12:19