anaconda/nb_conda_kernels

[nb_conda_kernels] couldn't call conda: 'ascii' codec can't decode byte 0xef in position 0

kofana opened this issue · 0 comments

I encountered the first error and I managed to solve it. At least, I thought so.
But then I encountered the next one.

First error itself

Everything was fine and I have not made any major changes but one day I encountered what you see down there.
This error prevented nb_conda_kernels from working (I have 5 kernels but it shows 0)

[E 20:24:01.888 NotebookApp] [nb_conda_kernels] couldn't call conda:
    'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
[I 20:24:01.889 NotebookApp] [nb_conda_kernels] enabled, 0 kernels found

This is my conda info:


     active environment : py_newer1
    active env location : C:\Users\ilyag\miniconda3\envs\py_newer1
            shell level : 1
       user config file : C:\Users\ilyag\.condarc
 populated config files : C:\Users\ilyag\.condarc
          conda version : 22.11.1
    conda-build version : not installed
         python version : 3.10.8.final.0
       virtual packages : __archspec=1=x86_64
                          __win=0=0
       base environment : C:\Users\ilyag\miniconda3  (writable)
      conda av data dir : C:\Users\ilyag\miniconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\ilyag\miniconda3\pkgs
                          C:\Users\ilyag\.conda\pkgs
                          C:\Users\ilyag\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\ilyag\miniconda3\envs
                          C:\Users\ilyag\.conda\envs
                          C:\Users\ilyag\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/22.11.1 requests/2.27.1 CPython/3.10.8 Windows/10 Windows/10.0.19044
          administrator : True
             netrc file : None
           offline mode : False

How I (thought that I) fixed the error

I still don't really understand where I have this non ASCII symboll, but after all I fixed it by changing decoding system to utf-8-sig instead of ascii in the function def _conda_info(self) in the file manager.py.
Before:

                p = subprocess.check_output([CONDA_EXE, "info", "--json"],
                                            shell=shell).decode('ascii')
                conda_info = json.loads(p)

I changed it to:

                p = subprocess.check_output([CONDA_EXE, "info", "--json"],
                                            shell=shell).decode('utf-8-sig')
                conda_info = json.loads(p)

Now all my kernels are found and the main one loads successfully when I launch the notebook:

[I 21:49:24.801 NotebookApp] [nb_conda_kernels] enabled, 5 kernels found
[I 21:49:44.537 NotebookApp] Kernel started: 87744234-455f-47e9-b2b0-cfc4408d7187, name: conda-env-py_newer1-py

BUT when I try to change kernel I get this:

[I 21:56:07.860 NotebookApp] Starting buffering for 87744234-455f-47e9-b2b0-cfc4408d7187:39c6fe2a8b5648b9956d0a3e22b47661
[I 21:56:07.944 NotebookApp] Kernel shutdown: 87744234-455f-47e9-b2b0-cfc4408d7187
[I 21:56:09.938 NotebookApp] Kernel started: 2b049dbc-a2b8-4d67-937a-66dce15a3fa9, name: conda-env-kino_lec_parse-py
Active code page: 65001
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
[I 21:56:12.934 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
Active code page: 65001
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
[I 21:56:15.947 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
Active code page: 65001
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
[I 21:56:18.967 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
Active code page: 65001
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
[I 21:56:21.982 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
Active code page: 65001
The filename, directory name, or volume label syntax is incorrect.
The filename, directory name, or volume label syntax is incorrect.
[W 21:56:25.004 NotebookApp] KernelRestarter: restart failed
[W 21:56:25.004 NotebookApp] Kernel 2b049dbc-a2b8-4d67-937a-66dce15a3fa9 died, removing from map.
[W 21:56:30.989 NotebookApp] Replacing stale connection: 2b049dbc-a2b8-4d67-937a-66dce15a3fa9:39c6fe2a8b5648b9956d0a3e22b47661

And it just fails to switch the kernel

I don't really understand what is wrong, cause it finds all my kernels and as I can see I don't have non-ASCII symbols in paths leading to them.
I do appreciate any help!