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

non-default kernel issue on Windows #49

Closed
azinsharaf opened this issue Dec 5, 2022 · 6 comments
Closed

non-default kernel issue on Windows #49

azinsharaf opened this issue Dec 5, 2022 · 6 comments

Comments

@azinsharaf
Copy link

I've tried euporie on WSL (with Ubuntu) and it works. Now I need to use it on Windows because my python package (arcpy) is just running on Windows. I installed it via pipx on Windows but cannot configure it with a non-default kernel. Is it something you can help?

my existing kernels:

C:\Users\asharaf>jupyter kernelspec list
Available kernels:
  python3    C:\Users\asharaf\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\share\jupyter\kernels\python3
  xpython    C:\Users\asharaf\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\share\jupyter\kernels\xpython

euporie configuration file:

PS C:\Users\asharaf\AppData\Local\euporie> cat .\config.json
{
  "color_scheme": "dark",
  "syntax_theme": "native",
  "notebook": {
    "expand": false,
    "always_show_tab_bar": true,
    "show_cell_borders": false,
    "kernel_connection_file": "C:\Users\asharaf\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\share\jupyter\kernels\python3\kernel.json",
    "kernel_name": "python3"
  },
  "console": {
    "color_scheme": "default",
    "syntax_theme": "dracula"
  },
  "preview": {
    "show_cell_borders": true
  }
}

euporie log:

image

@joouha
Copy link
Owner

joouha commented Dec 6, 2022

Hello,

The kernel_connection_file parameter in euporie's config allows you to connect to an existing running kernel instance by providing a kernel connection file. A kernel connection file contains the IP, ports, and authentication key needed to connect to an existing running instance of the kernel. Typically this file gets created when a kernel is launched.

The file C:\Users\asharaf\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\share\jupyter\kernels\python3\kernel.json is a kernelspec file. A kernel spec file tells Jupyter how to launch a particular kernel. So, as you have found, setting kernel_connection_file to a kernelspec file will not work.

Normally you can switch the kernel from within euporie-notebook by selecting Kernel > Change kernel from the menus - see here: https://euporie.readthedocs.io/en/latest/apps/notebook.html#changing-the-kernel

If your kernel does not show up on the list of available kernels in euporie, you need to register your kernel.

conda activate arcgispro-py3-clone
python -m ipykernel install --user --name python3-arcgispro --display-name "Python 3 (ArcGIS Pro)"

This should copy the python3 kernelspec folder to %APPDATA%\jupyter\kernels, adding the correct python interpreter path. It should now show in the list of available kernels in euporie.

You can find more information about kernelspecs in the jupyter_client documentation here:
https://jupyter-client.readthedocs.io/en/stable/kernels.html#kernelspecs

@azinsharaf
Copy link
Author

thanks @joouha . It works now. I removed the invalid config.json file and ran python -m ipykernel install --user --name python3-arcgispro --display-name "Python 3 (ArcGIS Pro)" as you mentioned. Now euporie notebook can recognize my python interpreter. Sweet!
The only question now is when I run jupyter notebook I see three kernels (the middle one is the one I just created). So why euporie couldn't use the existing one i already have. (maybe they are in a different location?)

image

image

@joouha
Copy link
Owner

joouha commented Dec 6, 2022

Are you running Jupyter Notebook from within your arcgispro-py3-clone conda environment?

@azinsharaf
Copy link
Author

azinsharaf commented Dec 6, 2022

yes

image

@joouha
Copy link
Owner

joouha commented Dec 6, 2022

OK, so that explains why those kernels show up in Jupyter Notebook and not in euporie.

I think you said you installed euporie with pipx - so euporie will be in a different Python environment to Jupyter Notebook and your custom kernels.

Jupyter and euporie both search for kernelspecs in several folders, including the share folder for the current Python environment (this is where kernelspecs for custom kernels usually get installed). Since Jupyter Notebook is running from the same environment in which the kernels are installed, it is able to find them.

Since Euporie is running in a different Python environment, it does not know anything about the environment with the custom kernels in, so does not find the kernelspecs.

By running python -m ipykernel install --user, you install a copy of the kernelspec to your user profile, where euporie can find it.

@joouha joouha closed this as completed Dec 6, 2022
@azinsharaf
Copy link
Author

Thanks for the great explanation.

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

2 participants