Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipyparallel causing problem in calling a qtconsole from an ipython jupyter notebook #922

Open
kdere opened this issue Feb 3, 2025 · 3 comments · May be fixed by ipython/ipykernel#1315
Open

Comments

@kdere
Copy link

kdere commented Feb 3, 2025

With the last several months, I have problems starting a qtconsole from a jupyter ipython notebook. The problem seems to be caused because I have ipyparallel imported. I get the following error code:

`get_ipython().run_line_magic('qtconsole', '')
`
File /usr/lib/python3.12/site-packages/IPython/core/interactiveshell.py:2480,


`with self.builtin_trap: result = fn(*args, **kwargs)
`
File /usr/lib/python3.12/site-packages/ipykernel/zmqshell.py:407, in KernelMagics.qtconsole(self, arg_s)

`if "ipyparallel" in sys.modules:
    from ipyparallel import bind_kernel
    bind_kernel()
    try:
        connect_qtconsole(argv=arg_split(arg_s, os.name == "posix"))
`
File /usr/lib/python3.12/site-packages/ipyparallel/init.py:51, in bind_kernel(**kwargs)

`     else:
        return app.bind_kernel(**kwargs)
        raise RuntimeError("bind_kernel must be called from an IPEngine instance")
`
RuntimeError: bind_kernel must be called from an IPEngine instance

I have not found anyone else having this problem.

thanks

@minrk
Copy link
Member

minrk commented Feb 4, 2025

The check isn't right. I guess bind_kernel used to be a no-op when not an engine, but now it raises, which I think makes more sense. ipython/ipykernel#1315 removes this call, since it really belongs in ipyparallel, if it belongs anywhere.

If you need a short-term workaround, you can do:

import ipyparallel
ipyparallel.bind_kernel = lambda : None

to disable bind_kernel, which should get past the error.

@kdere
Copy link
Author

kdere commented Feb 4, 2025

thanks for the prompt response.

the work-around works

however, I used ipyparallel in a package that is distributed on PyPI so a long term solution would be helpful

thanks for the help

@minrk
Copy link
Member

minrk commented Feb 4, 2025

ipython/ipykernel#1315 is the permanent fix, removing the call to bind_kernel in ipykernel. I'll see if I can fix it here as well, because there's clearly an expectation that bind_kernel is a no-op for a regular Kernel, which I didn't recall in some recent changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants