12-07-2024 03:51 AM
hello,
i have AF_UNIX error when using NC-get-config.py. I have windows and runing python ver 3.13.1. Please advise if this can be fixed?
Traceback (most recent call last):
File "c:\python\nc-get-config.py", line 32, in <module>
from ncclient import manager
File "C:\Users\chint\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\ncclient\manager.py", line 21, in <module>
from ncclient import operations
File "C:\Users\chint\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\ncclient\operations\__init__.py", line 16, in <module>
from ncclient.operations.rpc import RPC, RPCReply, RPCError, RaiseMode, GenericRPC
File "C:\Users\chint\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\ncclient\operations\rpc.py", line 20, in <module>
from ncclient.transport import SessionListener
File "C:\Users\chint\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\ncclient\transport\__init__.py", line 20, in <module>
from ncclient.transport.unixSocket import UnixSocketSession
File "C:\Users\chint\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\ncclient\transport\unixSocket.py", line 18, in <module>
from socket import AF_UNIX, SOCK_STREAM
ImportError: cannot import name 'AF_UNIX' from 'socket' (C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.496.0_x64__qbz5n2kfra8p0\Lib\socket.py)
Solved! Go to Solution.
12-08-2024 11:28 AM
Oh, my fault: The new version is not yet available on https://pypi.org/.
If you clone the repo and upgrade from there, you should be fine:
git clone https://github.com/ncclient/ncclient.git
cd ncclient
pip install -U .
HTH
Marcel
12-07-2024 04:09 AM
Try to upgrade your ncclient package, there was a change introduced [1] to import the unix sockets only for non-windows systems:
pip install ncclient --upgrade
[1]: https://github.com/ncclient/ncclient/commit/ad88686f4772ae883109a8f97a26708a352b89b8
12-08-2024 01:36 AM
i have the same error after upgrade the ncclient package.
12-08-2024 11:09 AM
@chinkevi not an expert here, but based on your error, I think this is due to the AF_UNIX socket type, which is not natively supported on windows as this is a unix specific socket type for local inter-process communication that doesn't exist in the windows socket implementation.
A quick way around this would be to install WSL and run your Python script within the Linux environment or run a VM with Linux installed.
12-08-2024 11:28 AM
Oh, my fault: The new version is not yet available on https://pypi.org/.
If you clone the repo and upgrade from there, you should be fine:
git clone https://github.com/ncclient/ncclient.git
cd ncclient
pip install -U .
HTH
Marcel
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide