pyroute2
pyroute2 copied to clipboard
Import of IPRoute on Windows fails
After updating to 0.6.10 (existing as well in 0.6.11 & 12) import of IPRoute fails on Windows:
from pr2modules.iproute import IPRoute
..\..\..\.venv\lib\site-packages\pr2modules\iproute\__init__.py:132: in <module>
from pr2modules import config
..\..\..\.venv\lib\site-packages\pr2modules\config\__init__.py:30: in <module>
signal_stop_remote = signal.SIGUSR1
E AttributeError: module 'signal' has no attribute 'SIGUSR1'
Thank you already in advance for looking into this!
Confirmed. Will be fixed until Friday.
NB: pyroute2 is neither tested, nor used on Windows platform actively. There is still no CI workflow for pyroute2+Windows. If you are a Windows user and can contribute with code, testing or feasible usecases — you're welcome.
@svinota I saw this bug is fixed in master 4b78de12, do you have a schedule when you're expecting to be released?
Applied the patch 4b78de1251877b69c69416db0dadf92508906dc4 but still got an import error:
..\..\..\.venv\Lib\site-packages\pr2modules\__init__.py:10: in <module>
import pyroute2 # noqa: F401
..\..\..\.venv\Lib\site-packages\pyroute2\__init__.py:77: in <module>
loaded = entry_point.load()
..\..\..\.venv\Lib\site-packages\importlib_metadata\__init__.py:207: in load
module = import_module(match.group('module'))
C:\Tools\Python3.11\Lib\importlib\__init__.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
..\..\..\.venv\Lib\site-packages\pyroute2\netlink\diag\__init__.py:1: in <module>
from socket import AF_INET, AF_INET6, AF_UNIX, IPPROTO_TCP, inet_ntop
E ImportError: cannot import name 'AF_UNIX' from 'socket' (C:\Tools\Python3.11\Lib\socket.py)
Can you please try the master branch? Thanks!
Did try, now the problem is because of the ImportError
suppress in __init__.py
the IPRoute module does not get imported and hence it cannot find IPRoute in my part of the code. The reason why the IPRoute import fails is:
cannot import name 'MSG_DONTWAIT' from 'socket' (C:\\Tools\\Python3.9\\lib\\socket.py)
For better readability, I removed the
if not sys.platform.startswith('win'):
raise
continue
Then we get the following error message:
test_ipr.py:3: in <module>
from pyroute2 import IPRoute
..\..\pyroute2\__init__.py:78: in <module>
loaded = entry_point.load()
C:\Tools\Python3.9\lib\importlib\metadata.py:77: in load
module = import_module(match.group('module'))
C:\Tools\Python3.9\lib\importlib\__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
..\..\pyroute2\netlink\event\__init__.py:2: in <module>
from pyroute2.netlink.generic import GenericNetlinkSocket
..\..\pyroute2\netlink\generic\__init__.py:23: in <module>
from pyroute2.netlink.nlsocket import NetlinkSocket
..\..\pyroute2\netlink\nlsocket.py:95: in <module>
from socket import (
E ImportError: cannot import name 'MSG_DONTWAIT' from 'socket' (C:\Tools\Python3.9\lib\socket.py)
Thanks, checking
Hello,
I have installed pyroute2 using pip (pip install pyroute2
) and got this error:
import pyroute2
Traceback (most recent call last):
File "C:\Users\Robin\AppData\Local\Programs\Python\Python310\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "C:\Users\Robin\AppData\Local\JetBrains\Toolbox\apps\PyCharm-C\ch-0\222.4345.23\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\Robin\projects\Shell\env\lib\site-packages\pyroute2\__init__.py", line 14, in <module>
from pyroute2.config.version import __version__
File "C:\Users\Robin\AppData\Local\JetBrains\Toolbox\apps\PyCharm-C\ch-0\222.4345.23\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\Robin\projects\Shell\env\lib\site-packages\pyroute2\config\__init__.py", line 30, in <module>
signal_stop_remote = signal.SIGUSR1
AttributeError: module 'signal' has no attribute 'SIGUSR1'
And i know pyroute2 isn't tested on windows but i found it on an other open source project