zeromq / pyzmq

PyZMQ: Python bindings for zeromq
http://zguide.zeromq.org/py:all
BSD 3-Clause "New" or "Revised" License
3.62k stars 635 forks source link

pyzmq 26, Windows 11: Bad file descriptor #1981

Open malgarop opened 3 months ago

malgarop commented 3 months ago

This is a pyzmq bug

What pyzmq version?

26.0.0

What libzmq version?

none

Python version (and how it was installed)

3.12.3

OS

windows 11

What happened?

When installing jupyter on a new windows machine, it will fail to connect to any python3 kernel, with the following error popup: "Error Starting KernelNetworkError when attempting to fetch resource."

To reproduce: On a Powershell on a Windows 11 machine with python 3.12.3:

'pip install jupyter'
'python -m jupyter notebook' or 'jupyter-lab'
start a new notebook, or open an existing one, with python3 kernel
process fails and error pops up. In the shell I get the following output:
"Bad file descriptor (C:\Users\runneradmin\AppData\Local\Temp\tmp9czwcdbh\build_deps\bundled_libzmq-src\src\epoll.cpp:73)"

It works after I uninstall pyzmq and reinstall the Dec 5, 2023 version:

'pip freeze | findstr pyzmq'
output: "pyzmq==26.0.0"
'pip uninstall pyzmq'
'pip install pyzmq==25.1.2'

Code to reproduce bug

pip install jupyter
python -m jupyter notebook' or 'jupyter-lab

Traceback, if applicable

Bad file descriptor (C:\Users\runneradmin\AppData\Local\Temp\tmp9czwcdbh\build_deps\bundled_libzmq-src\src\epoll.cpp:73)

More info

No response

minrk commented 3 months ago

Can I ask how you installed pyzmq and Python? Do you have any other Python versions available to test?

Can you run a basic script like:

import zmq
ctx = zmq.Context()
with ctx:
    with ctx.socket(zmq.PUSH) as s:
        s.bind("tcp://127.0.0.1:5555")
grvstick commented 2 months ago

same issue here. FYI @minrk, I've just run your code to confirm.

import zmq
ctx = zmq.Context()
with ctx:
    with ctx.socket(zmq.PUSH) as s:
        s.bind("tcp://127.0.0.1:5555")
Bad file descriptor (C:\Users\runneradmin\AppData\Local\Temp\tmpuk6z2au_\build\_deps\bundled_libzmq-src\src\epoll.cpp:73)

Also using python 3.12.3 via microsoft store(WIN 11)

malgarop commented 2 months ago

@minrk thanks for your patience, running the scripts you suggested results in: Bad file descriptor (C:\Users\runneradmin\AppData\Local\Temp\tmps23b75cz\build\_deps\bundled_libzmq-src\src\epoll.cpp:73)

I installed python via Mirosoft store on windows 11. Python pip installed pyzmq for me as a dependency for the module jupyter

minrk commented 2 months ago

Interesting that you both got it via the Store. Do you have access to another source, e.g. a miniconda install or Python.org installer? Just to test if it's related to the Python installation instead of the environment?

grvstick commented 2 months ago

@minrk just confirmed that it does not happen with python.org release of 3.12.3, both on jupyter lab and the test code you provided. I've failed to test conda, since jupyter is only seems to be able to run in conda packages, not pip. I wanted to test in pyzmq >= 26.0.0

jochoaAvant commented 2 months ago

For what it's worth, I get the same error using Python 3.11.9. I don't recall how I installed it.

r23-dias commented 2 months ago

Same here! I had the same error and the way i fixed it was by downgrading pyzmq to the version 25.1.2 (I was on the 26.0.3 version). Run windows powershell and unintstall the current version by using this command:

python -m pip uninstall pyzmq

Then install the version i talked about:

pip install pyzmq==25.1.2

Hope it helps!

EliAxcel commented 2 months ago
fnicolaim commented 2 months ago

Same here, my configuration is the same as the opener of the issue

bb-at-ss commented 1 month ago

Still getting this error with 26.0.3

AgentMC commented 1 month ago

I'd like to point out this is not the first time this exact issue happens: https://github.com/microsoft/vscode-jupyter/issues/8630 A test may be due.

minrk commented 1 month ago

That vscode issue is not at all related, as far as I can tell. Wrong link?

If you know how to write a test for this, I would love it. I test every situation I can find, but I've never been able to reproduce any of these issues myself, which makes testing very hard.

AgentMC commented 1 month ago

@minrk Well it's up to you to judge but the optics are the same: Windows, MS Store installation of Python, latest pyzmq installed automatically and image Except in my case it said that bad file descriptor was stderr when trying to launch an ipynb. That 8630 is how I found this repo and issue.

Sure I may be missing details but regardless, 25.1.2 solves it for me, just like in that entry downgrade solved it for them. ¯\_(ツ)_/¯

minrk commented 1 month ago

It is in the same general category of "a libzmq build is not compatible with a specific Windows situation" which can have many different causes, but often looks the same. Neither the affected Windows/Python nor the affected libzmq are the same, so no test could have caught both failures, and it's frustrating for me because it has nothing to do with pyzmq, it's all in libzmq.

Fortunately, it looks like this one might be feasible to reproduce, unlike the previous round, and the pyzmq 26 build system has more control over how libzmq is built, so I have a little more hope that someone can figure this one out.

Thanks everyone for reporting!

Alessandrob99 commented 1 month ago

Thanks man, u saved me after 2 days of hitting my head on a brick wall

Morsiusiurandum commented 1 week ago

Also encountered this issue on my new computer, but a few days ago I was able to start Jupyter using pyzmq==26.0.3 on my old computer