0

I'm trying to load kernel from conda environment and get following error when trying to do this:

`[I 22:10:35.989 NotebookApp] KernelRestarter: restarting kernel (5/5), new random ports
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
    from .connect import *
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\site-packages\ipykernel\connect.py", line 18, in <module>
    import jupyter_client
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
    from .connect import *
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\site-packages\jupyter_client\connect.py", line 21, in <module>
    import zmq
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\site-packages\zmq\__init__.py", line 50, in <module>
    from zmq import backend
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
    raise value
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "C:\ProgramData\Anaconda3\envs\ImageAI\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: DLL load failed: Не найден указанный модуль.
[W 22:10:39.032 NotebookApp] KernelRestarter: restart failed
[W 22:10:39.032 NotebookApp] Kernel 7695680a-c4cf-4408-a228-a36587c6acee died, removing from map.
[W 22:11:20.915 NotebookApp] Timeout waiting for kernel_info reply from 7695680a-c4cf-4408-a228-a36587c6acee
[E 22:11:20.917 NotebookApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: 7695680a-c4cf-4408-a228-a36587c6acee)
[W 22:11:21.949 NotebookApp] 404 GET /api/kernels/7695680a-c4cf-4408-a228-a36587c6acee/channels?session_id=a461c65a632c4842918b17939d5595f1 (::1): Kernel does not exist: 7695680a-c4cf-4408-a228-a36587c6acee
[W 22:11:21.963 NotebookApp] 404 GET /api/kernels/7695680a-c4cf-4408-a228-a36587c6acee/channels?session_id=a461c65a632c4842918b17939d5595f1 (::1) 16.000000ms referer=None
[W 22:11:23.987 NotebookApp] Replacing stale connection: 7695680a-c4cf-4408-a228-a36587c6acee:a461c65a632c4842918b17939d5595f1`

The error is ImportError: DLL load failed: The specific module was not found. I've tried to reinstall environment and jupyter and also tried to reinstall pyzmq with pip uninstall pyzmq and pip install pyzmq. I get no problem with running my default kernel.

2 Answers2

1

Short Answer

You might be able to get away with just:

python -m ipykernel install --user --name=my_env_name

Long Answer

You can run jupyter kernelspec list to see your available kernels.

Depending on your operating system and how you installed Jupiter (user vs. system) you should be able to find your kernel definitions in of these directories:

  • /usr/share/jupyter/kernels (Linux/Mac)
  • /usr/local/share/jupyter/kernels (Linux/Mac)
  • {sys.prefix}/share/jupyter/kernels (Linux/Mac)
  • ~/.local/share/jupyter/kernels (Linux-user)
  • ~/Library/Jupyter/kernels (Mac-user)
  • %APPDATA%\jupyter\kernels (Windows)
  • %PROGRAMDATA%\jupyter\kernels (Windows)

The definitions look something like:

{
 "argv": ["python3", "-m", "IPython.kernel",
          "-f", "{connection_file}"],
 "display_name": "Python 3",
 "language": "python"
}

Your actual definition may look different so just copy whatever you have there and change the main arg so that it points to the particular python instance that you want to use and give it some "display_name" so you can recognise it in Jupyter.

In Jupyter whenever you create a new notebook you can select one of these kernels (you can also switch between them in an existing notebook).

So, check which kernel you are using, which kernels are defined in your spec, add the one you actually want to use if necessary and make sure you select the right one in the Jupyter UI. That should be it - good luck.

P.S. this is roughly what ipykernel install should do anyway.

rudolfovic
  • 3,163
  • 2
  • 14
  • 38
1

Solution was to run jupyter-notebook whithin activated conda environment, after that kernel selected and loaded correctly.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 09 '22 at 00:46