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

kernelspec_from_language misses kernel for conda environments #1137

Open
kjohnsen opened this issue Oct 16, 2023 · 0 comments
Open

kernelspec_from_language misses kernel for conda environments #1137

kjohnsen opened this issue Oct 16, 2023 · 0 comments

Comments

@kjohnsen
Copy link

kjohnsen commented Oct 16, 2023

Hello, I'm trying to execute a notebook from the command line and am getting the error "No kernel found that matches the current python executable," but I for sure have ipykernel in my environment. After some debugging I found the problem here. The problem is cmd = kernel_specs.argv[0] returns just python for conda (well, I'm using mamba) environments, at least with my setup. So then on line 39 it compares python to the executable path /home/me/mambaforge/envs/myenv/bin/python with os.path.samefile and skips it.

It looks like it'll take some playing around with the info in kernel_specs.argv to get a reliable absolute path to the executable which can be compared to sys.executable? The problem is, these don't appear to be very consistent:

sys.executable = /home/kyle/mambaforge/envs/cleo10/bin/python3.10

python3 ['python', '-m', 'ipykernel_launcher', '-f', '{connection_file}']
conda-env-cleo-py ['python', '-m', 'nb_conda_kernels.runner', '/home/kyle/mambaforge', '/home/kyle/mambaforge/envs/cleo', 'python', '-m', 'ipykernel_launcher', '-f', '{connection_file}']
conda-env-miniconda3-py ['python', '-m', 'nb_conda_kernels.runner', '/home/kyle/mambaforge', '/home/kyle/miniconda3', '/home/kyle/miniconda3/bin/python', '-m', 'ipykernel_launcher', '-f', '{connection_file}']
conda-env-neo-py ['python', '-m', 'nb_conda_kernels.runner', '/home/kyle/mambaforge', '/home/kyle/mambaforge/envs/neo', '/home/kyle/mambaforge/envs/neo/bin/python', '-m', 'ipykernel_launcher', '-f', '{connection_file}']
conda-env-cleo10-py ['python', '-m', 'nb_conda_kernels.runner', '/home/kyle/mambaforge', '/home/kyle/mambaforge/envs/cleo10', 'python', '-m', 'ipykernel_launcher', '-f', '{connection_file}']
conda-env-torch-py ['python', '-m', 'nb_conda_kernels.runner', '/home/kyle/mambaforge', '/home/kyle/mambaforge/envs/torch', 'python', '-m', 'ipykernel_launcher', '-f', '{connection_file}']
conda-root-py ['python', '-m', 'nb_conda_kernels.runner', '/home/kyle/mambaforge', '/home/kyle/mambaforge', '/home/kyle/mambaforge/bin/python', '-m', 'ipykernel_launcher', '-f', '{connection_file}']

System details:

Ubuntu (on WSL) 18.04
jupytext 0.15.1
jupyter_client 8.1.0
@kjohnsen kjohnsen changed the title kernelspec_from_language misses kernel for currently active environment kernelspec_from_language misses kernel for conda environments Oct 16, 2023
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

No branches or pull requests

1 participant