spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.38k stars 1.63k forks source link

"An error ocurred while starting the kernel" about wrong version of spyder-kernels is displayed despite being installed #17027

Closed leavor closed 2 years ago

leavor commented 2 years ago

Problem Description

To create a new virtual environment, use the following command:

conda create -n python3.8.12 python=3.8.12 spyder=5.2.1

Start spyder, the following error occurred: image

Restart kernel, the following occurred:

Python 3.8.12 | packaged by conda-forge | (default, Sep 16 2021, 01:40:49) [MSC v.1916 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 7.29.0 -- An enhanced Interactive Python.
Cannot restart a kernel not started by Spyder

Versions

Dependencies

# Mandatory:
atomicwrites >=1.2.0          :  1.4.0 (OK)
chardet >=2.0.0               :  4.0.0 (OK)
cloudpickle >=0.5.0           :  2.0.0 (OK)
cookiecutter >=1.6.0          :  1.7.2 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.1.0 (OK)
IPython >=7.6.0               :  7.29.0 (OK)
jedi >=0.17.2;<0.19.0         :  0.18.0 (OK)
jellyfish >=0.7               :  0.8.9 (OK)
jsonschema >=3.2.0            :  3.2.0 (OK)
keyring >=17.0.0              :  23.4.0 (OK)
nbconvert >=4.0               :  6.1.0 (OK)
numpydoc >=0.6.0              :  1.1.0 (OK)
paramiko >=2.4.0              :  2.7.2 (OK)
parso >=0.7.0;<0.9.0          :  0.8.2 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.8.0 (OK)
pygments >=2.0                :  2.10.0 (OK)
pylint >=2.5.0                :  2.9.6 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.3.2;<1.4.0          :  1.3.3 (OK)
pylsp_black >=1.0.0           :  1.0.0 (OK)
qdarkstyle =3.0.2             :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.1.10 (OK)
qtawesome >=1.0.2             :  1.0.3 (OK)
qtconsole >=5.2.1;<5.3.0      :  5.2.2 (OK)
qtpy >=1.5.0                  :  1.10.0 (OK)
rtree >=0.9.7                 :  0.9.7 (OK)
setuptools >=49.6.0           :  58.0.4 (OK)
sphinx >=0.6.6                :  4.2.0 (OK)
spyder_kernels >=2.2.0;<2.3.0 :  2.2.0 (OK)
textdistance >=4.2.0          :  4.2.1 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  2.1.6 (OK)
zmq >=17                      :  22.3.0 (OK)

# Optional:
cython >=0.21                 :  None (NOK)
matplotlib >=2.0.0            :  None (NOK)
numpy >=1.7                   :  None (NOK)
pandas >=1.1.1                :  None (NOK)
scipy >=0.17.0                :  None (NOK)
sympy >=0.7.3                 :  None (NOK)
leavor commented 2 years ago

I also created python=3.9.7, the issue is the same!

ccordoba12 commented 2 years ago

Hey @leavor, thanks for reporting. Please open the Anaconda prompt and run there

spyder --reset

That should fix your problem, which is most likely caused by not having the right version of Spyder-kernels in the environment you have selected in Preferences > Python interpreter.

leavor commented 2 years ago

@ccordoba12, do as you say, can solve this error

ccordoba12 commented 2 years ago

Great! Thanks for letting us know about it.

To not force users to do a reset to solve this problem, we'll inform them what's the interpreter that doesn't have the right version of spyder-kernels installed in the message you displayed in the first screenshot.

I think that will help them to understand to better understand what's happening in this case.

Martlexisn commented 2 years ago

Hey @leavor, thanks for reporting. Please open the Anaconda prompt and run there

spyder --reset

That should fix your problem, which is most likely caused by not having the right version of Spyder-kernels in the environment you have selected in Preferences > Python interpreter.

Hey @ccordoba12 ,

I saw you helping many people in the same case of kernels problems. I also have this problem with the same error message. It tell me that "Your Python environment or installation doesn't have the spyder-kernels module or the right version of it installed". So I did what you said and went in preference and changed the python interpreter to "default" (it was before in "- /opt/anaconda3/bin/python"). I'm not very good at understanding that but I guess I'M now using the basic python of my computer and not the one from anaconda ???. And well, it's working now, but it's means im not having any package that was on my anaconda environment. ??

ccordoba12 commented 2 years ago

I'm not very good at understanding that but I guess I'M now using the basic python of my computer and not the one from anaconda ???

Not exactly. That simply means that you're using the same Python interpreter on which Spyder is running (because Spyder is also a Python application).

And well, it's working now, but it's means im not having any package that was on my anaconda environment. ??

Possibly. Did you use our macOS app to install Spyder?

jcborgesjr commented 1 year ago

Hey @leavor, thanks for reporting. Please open the Anaconda prompt and run there

spyder --reset

That should fix your problem, which is most likely caused by not having the right version of Spyder-kernels in the environment you have selected in Preferences > Python interpreter.

It worked once, but the problem reoccurred.

erdoganb commented 1 year ago

I have the same issue. I've installed the spyder alone. Without anaconda. and also, in spyder's terminal, when i go pip install "the kernels" says: no module named "pip" what am i doing wrong?

ccordoba12 commented 1 year ago

@erdoganb, pip is not provided in our Windows and Mac installers so that people can't easily break them by installing other things with it. If you want to use other packages that don't come with the installers, please read our documentation on how to do that.

darcycordell commented 1 year ago

What is the "Anaconda Prompt" and how do I open it?

ccordoba12 commented 1 year ago

@darcycordell, if you're on Windows, look for "Anaconda Prompt" in the Start menu. If not, simply open a terminal (Terminal.app on Mac or Konsole/Gnome Terminal on Linux).

Then, see the video shown in the link I posted in my previous comment to understand what you need to do.