spyder: Connecting to the kernel never succeeds.

Description

What steps will reproduce the problem?

  1. Create an environment using miniforge containing Python 3.11 and spyder-kernels.
  2. In the Spyder preferences window, set the Python interpreter to that of this environment.
  3. Open a new IPython console in Spyder.

The resulting behaviour is that the console continuously shows “Connecting to kernel…” without ever succeeding. This issue does not appear to be affected by the presence of any other packages in the environment.

If I start with the built-in Python interpreter (which works correctly), perform steps 1 and 2, and then use the restart kernel command, horizontal lines repeatedly appear one after the other. This suggests to me, along with some other testing, that the kernel is being repeatedly started but not successfully connected to.

Versions

  • Spyder version: 5.5.3 (standalone)
  • Python version: 3.8.10 64-bit
  • Qt version: 5.15.2
  • PyQt5 version: 5.15.10
  • Operating System: Windows-10-10.0.22631-SP0

Dependencies

# Mandatory:
atomicwrites >=1.2.0          :  1.4.1 (OK)
chardet >=2.0.0               :  5.2.0 (OK)
cloudpickle >=0.5.0           :  3.0.0 (OK)
cookiecutter >=1.6.0          :  2.6.0 (OK)
diff_match_patch >=20181111   :  20230430 (OK)
intervaltree                  :  None (OK)
IPython >=8.12.2,<8.13.0      :  8.12.3 (OK)
jedi >=0.17.2,<0.20.0         :  0.19.1 (OK)
jellyfish >=0.7               :  1.0.3 (OK)
jsonschema >=3.2.0            :  4.21.1 (OK)
keyring >=17.0.0              :  24.3.1 (OK)
nbconvert >=4.0               :  7.16.2 (OK)
numpydoc >=0.6.0              :  1.6.0 (OK)
paramiko >=2.4.0              :  3.4.0 (OK)
parso >=0.7.0,<0.9.0          :  0.8.3 (OK)
pexpect >=4.4.0               :  4.9.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.9.8 (OK)
pygments >=2.0                :  2.17.2 (OK)
pylint >=2.5.0,<3.1           :  3.0.4 (OK)
pylint_venv >=3.0.2           :  3.0.3 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.10.0,<1.11.0        :  1.10.1 (OK)
pylsp_black >=2.0.0,<3.0.0    :  2.0.0 (OK)
qdarkstyle >=3.2.0,<3.3.0     :  3.2.3 (OK)
qstylizer >=0.2.2             :  0.2.2 (OK)
qtawesome >=1.2.1,<1.3.0      :  1.2.3 (OK)
qtconsole >=5.5.1,<5.6.0      :  5.5.1 (OK)
qtpy >=2.1.0                  :  2.4.1 (OK)
rtree >=0.9.7                 :  1.2.0 (OK)
setuptools >=49.6.0           :  69.2.0 (OK)
sphinx >=0.6.6                :  7.1.2 (OK)
spyder_kernels >=2.5.1,<2.6.0 :  2.5.1 (OK)
textdistance >=4.2.0          :  4.6.1 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog                      :  4.0.0 (OK)
zmq >=24.0.0                  :  25.1.2 (OK)

# Optional:
cython >=0.21                 :  3.0.9 (OK)
matplotlib >=3.0.0            :  3.7.5 (OK)
numpy >=1.7                   :  1.24.4 (OK)
pandas >=1.1.1                :  2.0.3 (OK)
scipy >=0.17.0                :  1.10.1 (OK)
sympy >=0.7.3                 :  1.12 (OK)

Environment

Environment
# packages in environment at C:\Users\Kiki Lu\.conda\envs\quacktest_basic_extreme:
#
# Name                    Version                   Build  Channel
asttokens                 2.4.1              pyhd8ed1ab_0    conda-forge
bzip2                     1.0.8                hcfcfb64_5    conda-forge
ca-certificates           2024.2.2             h56e8100_0    conda-forge
cloudpickle               3.0.0              pyhd8ed1ab_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
comm                      0.2.2              pyhd8ed1ab_0    conda-forge
debugpy                   1.8.1           py311h12c1d0e_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
exceptiongroup            1.2.0              pyhd8ed1ab_2    conda-forge
executing                 2.0.1              pyhd8ed1ab_0    conda-forge
importlib-metadata        7.1.0              pyha770c72_0    conda-forge
importlib_metadata        7.1.0                hd8ed1ab_0    conda-forge
ipykernel                 6.29.3             pyha63f2e9_0    conda-forge
ipython                   8.22.2             pyh7428d3b_0    conda-forge
jedi                      0.19.1             pyhd8ed1ab_0    conda-forge
jupyter_client            8.6.1              pyhd8ed1ab_0    conda-forge
jupyter_core              5.7.2           py311h1ea47a8_0    conda-forge
libexpat                  2.6.2                h63175ca_0    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
libsodium                 1.0.18               h8d14728_1    conda-forge
libsqlite                 3.45.2               hcfcfb64_0    conda-forge
libzlib                   1.2.13               hcfcfb64_5    conda-forge
matplotlib-inline         0.1.6              pyhd8ed1ab_0    conda-forge
nest-asyncio              1.6.0              pyhd8ed1ab_0    conda-forge
openssl                   3.2.1                hcfcfb64_1    conda-forge
packaging                 24.0               pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pip                       24.0               pyhd8ed1ab_0    conda-forge
platformdirs              4.2.0              pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.42             pyha770c72_0    conda-forge
psutil                    5.9.8           py311ha68e1ae_0    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
pygments                  2.17.2             pyhd8ed1ab_0    conda-forge
python                    3.11.8          h2628c8c_0_cpython    conda-forge
python-dateutil           2.9.0              pyhd8ed1ab_0    conda-forge
python_abi                3.11                    4_cp311    conda-forge
pywin32                   306             py311h12c1d0e_2    conda-forge
pyzmq                     25.1.2          py311h9250fbb_0    conda-forge
setuptools                69.2.0             pyhd8ed1ab_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
spyder-kernels            2.5.1           win_pyh7428d3b_0    conda-forge
stack_data                0.6.2              pyhd8ed1ab_0    conda-forge
tk                        8.6.13               h5226925_1    conda-forge
tornado                   6.4             py311ha68e1ae_0    conda-forge
traitlets                 5.14.2             pyhd8ed1ab_0    conda-forge
typing_extensions         4.10.0             pyha770c72_0    conda-forge
tzdata                    2024a                h0c530f3_0    conda-forge
ucrt                      10.0.22621.0         h57928b3_0    conda-forge
vc                        14.3                hcf57466_18    conda-forge
vc14_runtime              14.38.33130         h82b7239_18    conda-forge
vs2015_runtime            14.38.33130         hcb4865c_18    conda-forge
wcwidth                   0.2.13             pyhd8ed1ab_0    conda-forge
wheel                     0.43.0             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h8d14728_0    conda-forge
zeromq                    4.3.5                h63175ca_1    conda-forge
zipp                      3.17.0             pyhd8ed1ab_0    conda-forge

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Just in case, created #22028 . To test if the fix helps, you can download the Windows installer generated by that PR (note that running it will uninstall the Spyder version you are using!): https://github.com/spyder-ide/spyder/actions/runs/8853573213?pr=22028

I am happy to report that this version works. For the first time in many weeks, Spyder runs in a usable form on the institutional computer.

Did you close the console where you started the command I posted? That could be the cause of this.

The symptom involving the file being opened automatically at startup occurred before I ever tried your command in any form.

Thank you to both of you for your patience and effort.

Just in case, created #22028 . To test if the fix helps, you can download the Windows installer generated by that PR (note that running it will uninstall the Spyder version you are using!): https://github.com/spyder-ide/spyder/actions/runs/8853573213?pr=22028

you could try to run our activation command directly, i.e. something like this:

Checking the command I can reproduce the behavior described at https://github.com/spyder-ide/spyder/issues/21937#issuecomment-2068184036 I see that a kernel starts but instead of the full path to the kernel connection file, the message shows a truncated one.

My guess is that the kernel connection file is not quoted in our activation script and that’s what’s causing this problem.

I think that’s correct. @meltingSnowdrift could you check if changing C:\Program Files\Spyder\pkgs\spyder\plugins\ipythonconsole\scripts\conda-activate.bat line 27

https://github.com/spyder-ide/spyder/blob/1d17d91d231030f99c96245168e4267bf26a150a/spyder/plugins/ipythonconsole/scripts/conda-activate.bat#L27

in your Spyder installation for something like

"%CONDA_ENV_PYTHON%" -m spyder_kernels.console -f "%SPYDER_KERNEL_SPEC%"

helps?

Let us know!

@dalthviz, could you help me with this one? For this you’d need to create a Windows account with spaces on its name and use our app to start an external kernel on it. If everything goes well, you should be able to reproduce @meltingSnowdrift’s issue.

If that doesn’t work, you could try to run our activation command directly, i.e. something like this:

"C:\Program Files\Spyder\pkgs\spyder\plugins\ipythonconsole\scripts\conda-activate.bat" "C:/Program Files/Spyder/pkgs/spyder/bin/micromamba.exe" "C:/Users/<user with spaces>/Miniconda3/envs/myenv" "C:\Users\<user with spaces>\Miniconda3\envs\myenv\python.exe" "C:\Users\<user with spaces>\AppData\Roaming\jupyter\runtime\kernel-<available-id>.json"

My guess is that the kernel connection file is not quoted in our activation script and that’s what’s causing this problem.