You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've received several reports from users where a Python kernel fails to launch when started by a Jupyter client running in a virtual environment (e.g. joouha/euporie#25, joouha/euporie#75), and I've tracked down the cause to these lines of code in jupyter_client.
Let's say I have ipykernel installed in my system Python environment, and I want to run this kernel from a client (which uses jupyter_client) installed in a virtual environment:
jupyter_client replaces the python command in the kernelspec argv line with the path to the interpreter on which jupyter_client is running. This is implemented here:
I'm really not sure this is expected or desirable behaviour. There is a comment stating the following:
if the current process is in an env and has been launched by abspath without activating the env, python on PATH may not be sys.executable, but it should be.
but I don't think this assumption is correct, and I don't understand what problem was this originally implemented to solve.
The text was updated successfully, but these errors were encountered:
Thanks for your reply, but I think you have misunderstood this issue I described:
I'm writing a new Jupyter client which I want users to run from a virtual environment (using pipx). My client does not depend on ipykernel.
Typically the user will have ipykernel (and a corresponding kernelspec) installed in their system prefix.
When the user tries to launch a kernel from the system kernelspec it fails, because jupyter_client incorrectly edits the kernelspec, substituting the python argv command with the absolute path of the interpreter in the client's venv.
Since ipykernel is not installed in the pipx venv, launching the kernel fails.
I think in the case of a non-absolute python command, cmd[0] should be set to sys._base_executable, unless the client is running in the same prefix that the connection_file is located, in which case cmd[0] could reasonably be set to sys.executable.
I've received several reports from users where a Python kernel fails to launch when started by a Jupyter client running in a virtual environment (e.g. joouha/euporie#25, joouha/euporie#75), and I've tracked down the cause to these lines of code in
jupyter_client
.Let's say I have
ipykernel
installed in my system Python environment, and I want to run this kernel from a client (which usesjupyter_client
) installed in a virtual environment:jupyter_client
replaces thepython
command in the kernelspecargv
line with the path to the interpreter on whichjupyter_client
is running. This is implemented here:https://github.com/jupyter/jupyter_client/blob/ed7f9c27b0ae054e2b87d581f6252d240f2e6686/jupyter_client/manager.py#LL273C1-L284C36
I'm really not sure this is expected or desirable behaviour. There is a comment stating the following:
but I don't think this assumption is correct, and I don't understand what problem was this originally implemented to solve.
The text was updated successfully, but these errors were encountered: