I’m using an Arch Linux machine and trying to run the following code from a Python file.
socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
and it keeps telling me that
AttributeError: module 'socket' has no attribute 'AF_UNIX'
Things tried
- Some posts claim this error occurs on Windows but obviously that isn’t the case.
sys.platform
printslinux
- Code works on my Mac which was running Python3.9
- Downgraded from Python3.12 to Python3.9 on the Linux machine and still no luck
socket.AF_INET
has the same issue- running
python -c "import socket; socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
returns the same error - error when using system binary python, conda python and venv python
- running it in the interactive shell has no issue however.