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

spyder kernels installed but not recognised? #17608

Closed
5 of 10 tasks
dixonb3 opened this issue Apr 4, 2022 · 30 comments
Closed
5 of 10 tasks

spyder kernels installed but not recognised? #17608

dixonb3 opened this issue Apr 4, 2022 · 30 comments

Comments

@dixonb3
Copy link

dixonb3 commented Apr 4, 2022

Issue Report Checklist

  • Searched the issues page for similar reports
  • Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • Could not reproduce inside jupyter qtconsole (if console-related)
  • Tried basic troubleshooting (if a bug/error)
    • Restarted Spyder
    • Reset preferences with spyder --reset
    • Reinstalled the latest version of Anaconda
    • Tried the other applicable steps from the Troubleshooting Guide
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

I'm a novice so forgive my ignorance!
I'm using a different python environment to spyder's default. I have checked that the correct version of spyder-kernels is installed in this environment, however when using spyder I still get the following message in the IPython console:

The Python environment or installation whose interpreter is located at
C:\Program Files\Python39\python.exe
doesn't have the spyder‑kernels module or the right version of it installed (>= 2.3.0 and < 2.4.0). Without this module is not possible for Spyder to create a console for you.

You can install it by activating your environment (if necessary) and then running in a system terminal:
conda install spyder‑kernels=2.3
or
pip install spyder‑kernels==2.3.*

The correct version is definitely installed:

C:\Users\dixonb3>pip list
Package Version


asttokens 2.0.5
backcall 0.2.0
cloudpickle 1.6.0
colorama 0.4.4
cycler 0.10.0
debugpy 1.6.0
decorator 5.0.9
entrypoints 0.4
executing 0.8.3
ipykernel 6.12.1
ipython 7.32.0
ipython-genutils 0.2.0
jedi 0.18.0
jupyter-client 7.2.1
jupyter-core 4.9.2
kiwisolver 1.3.1
matplotlib 3.4.2
matplotlib-inline 0.1.2
nest-asyncio 1.5.5
numpy 1.21.0
packaging 21.3
parso 0.8.2
pickleshare 0.7.5
Pillow 8.2.0
pip 21.1.1
prompt-toolkit 3.0.19
psutil 5.9.0
pure-eval 0.2.2
pydicom 2.2.2
Pygments 2.9.0
pyparsing 2.4.7
python-dateutil 2.8.2
pywin32 301
pyzmq 22.3.0
setuptools 56.0.0
six 1.16.0
spyder-kernels 2.3.0
stack-data 0.2.0
tornado 6.1
traitlets 5.1.1
wcwidth 0.2.5

And the executable below matches the location I have set in the spyder python interpreter preferences:

C:\Users\dixonb3>python
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import sys
print(sys.executable)
C:\Program Files\Python39\python.exe

What steps reproduce the problem?

  1. Opening spyder

What is the expected output? What do you see instead?

Expected: functioning iPython console.
Seen instead: error as above (no spyder-kernels >= 2.3.0 despite it being installed)

Versions

  • Spyder version: 5.3.0 None
  • Python version: 3.8.10 64-bit
  • Qt version: 5.15.2
  • PyQt5 version: 5.15.6
  • Operating System: Windows 10

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.3 (OK)
diff_match_patch >=20181111          :  20200713 (OK)
intervaltree                         :  None (OK)
IPython >=7.31.1;<8.0.0              :  7.32.0 (OK)
jedi >=0.17.2;<0.19.0                :  0.18.1 (OK)
jellyfish >=0.7                      :  0.9.0 (OK)
jsonschema >=3.2.0                   :  4.4.0 (OK)
keyring >=17.0.0                     :  23.5.0 (OK)
nbconvert >=4.0                      :  6.4.5 (OK)
numpydoc >=0.6.0                     :  1.2.1 (OK)
paramiko >=2.4.0                     :  2.10.3 (OK)
parso >=0.7.0;<0.9.0                 :  0.8.3 (OK)
pexpect >=4.4.0                      :  4.8.0 (OK)
pickleshare >=0.4                    :  0.7.5 (OK)
psutil >=5.3                         :  5.9.0 (OK)
pygments >=2.0                       :  2.11.2 (OK)
pylint >=2.5.0                       :  2.13.3 (OK)
pyls_spyder >=0.4.0                  :  0.4.0 (OK)
pylsp >=1.4.1;<1.5.0                 :  1.4.1 (OK)
pylsp_black >=1.2.0                  :  1.2.0 (OK)
qdarkstyle >=3.0.2;<3.1.0            :  3.0.3 (OK)
qstylizer >=0.1.10                   :  0.2.1 (OK)
qtawesome >=1.0.2                    :  1.1.1 (OK)
qtconsole >=5.3.0;<5.4.0             :  5.3.0 (OK)
qtpy >=2.0.1                         :  2.0.1 (OK)
rtree >=0.9.7                        :  0.9.7 (OK)
setuptools >=49.6.0                  :  61.2.0 (OK)
sphinx >=0.6.6                       :  4.5.0 (OK)
spyder_kernels >=2.3.0;<2.4.0        :  2.3.0 (OK)
textdistance >=4.2.0                 :  4.2.2 (OK)
three_merge >=0.1.1                  :  0.1.1 (OK)
watchdog                             :  2.1.7 (OK)
zmq >=17                             :  22.3.0 (OK)

# Optional:
cython >=0.21                        :  0.29.28 (OK)
matplotlib >=3.0.0                   :  3.5.1 (OK)
numpy >=1.7                          :  1.22.3 (OK)
pandas >=1.1.1                       :  1.4.1 (OK)
scipy >=0.17.0                       :  1.8.0 (OK)
sympy >=0.7.3                        :  1.10.1 (OK)

# Spyder plugins:
spyder_terminal.terminalplugin 1.2.2 :  1.2.2 (OK)

Extremely grateful for any help- I'm going insane.

@ccordoba12
Copy link
Member

Hey @dixonb3, thanks for reporting. Please open a system terminal (i.e. cmd.exe), run there

python -m spyder_kernels.console

and paste here the contents printed on it after that.

@dixonb3
Copy link
Author

dixonb3 commented Apr 5, 2022

Hi @ccordoba12 , thanks for the reply. See below:

C:\Users\dixonb3>python -m spyder_kernels.console
NOTE: When using the ipython kernel entry point, Ctrl-C will not work.

To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.

To read more about this, see ipython/ipython#2049

To connect another client to this kernel, use:
--existing kernel-16916.json

@ccordoba12
Copy link
Member

Ok, that means that the kernel is working correctly.

@dalthviz, can you check if our Windows app can connect to an environment in which spyder-kernels was installed with pip?

@dalthviz
Copy link
Member

dalthviz commented Apr 5, 2022

@ccordoba12 I was able to use an interpreter with spyder-kernels installed with pip (although it is a conda env). @dixonb3 after changing the interpreter did you created a new console or restarted the one showing you the spyder-kernels version message?

@dixonb3
Copy link
Author

dixonb3 commented Apr 6, 2022

@dalthviz: I created a new console and that's when the spyder-kernels message appeared. It may be worth mentioning I got the same issue with a previous version of spyder (5.1.1?).
I upgraded to spyder 5.3.0 in the hope that this problem would be solved.
I previously had everything working in yet another spyder version (5.0.1 I think), so I know spyder-kernels can run, with a similar setup (i.e. python interpreter different to spyder's default, and all packages installed using pip)- indeed this is how it is currently working for a colleague of mine.
Obviously with each change in version I have upgraded all required packages using pip- but it still isn't working.

@dalthviz
Copy link
Member

dalthviz commented Apr 6, 2022

Could you run spyder in debug mode and post here the log file? For that you can go to File > Restart in debug mode and select the Verbose option. After that, Spyder should restart and start generating a spyder-debug.log file located at the Spyder config directory (.spyder-py3 in your user folder) capturing more details of the usage of Spyder (maybe there some traceback could appear indicating a more clear reason about what is missing in your interpreter).

Also , thinking about your Python installation, you are using a standalone version of Python as custom interpreter, right? And to install spyder-kernels you don't actually use an environment but that sort of global installation? What happens when you import spyder_kernels in the cmd with the Python interpreter and run spyder_kernels.__version__?

Let us know!

@dixonb3
Copy link
Author

dixonb3 commented Apr 7, 2022

spyder-debug.log

Hi @dalthviz ,
I've attached the spyder-debug.log file as requested. Running python through cmd as requested, I get the following:

C:\Users\dixonb3>python
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import spyder_kernels
spyder_kernels.version
'2.3.0'

So the correct version is definitely installed. To prove I'm using the python installation I have pointed spyder to- here's the location of the executable when running python via cmd:

import sys
print(sys.executable)
C:\Program Files\Python39\python.exe

And here are the first two lines of the error appearing in the spyder IPython Console:

The Python environment or installation whose interpreter is located at
C:\Program Files\Python39\python.exe

I just don't understand what is going wrong. Thanks very much for your continued help.

@dalthviz
Copy link
Member

dalthviz commented Apr 8, 2022

Checked the debug log file but I didn't see anything out of normal. The log even shows the start of the console kernel too:

2022-04-07 12:38:21,585 [DEBUG] [traitlets] -> Starting kernel: ['C:\\Program Files\\Python39\\python.exe', '-m', 'spyder_kernels.console', '-f', 'C:\\Users\\dixonb3\\AppData\\Roaming\\jupyter\\runtime\\kernel-37af26351573.json']
2022-04-07 12:38:21,597 [DEBUG] [traitlets] -> Connecting to: tcp://127.0.0.1:53812
2022-04-07 12:38:21,622 [DEBUG] [traitlets] -> connecting heartbeat channel to tcp://127.0.0.1:53811

So seems like for some reason the spyder.utils.programs.is_module_installed validation function is not working in your case with the only pip interpreter and so preventing the Spyder interface from connecting to the initialized kernel.

Could you try to use the option to connect manually to a initialized kernel at Consoles > Connect to an existing kernel to connect to the kernel that seems like is being started? For that start Spyder again in debug mode, wait for the log to show the path for the .json file with the config to connect to the kernel (it will be a log entry similar to the one above) and use the Connect to an existing kernel option with the logged path.

Also, as a workaround, you could try to use the command metioned by @ccordoba12 to start manually a kernel and then use the Connect to an existing kernel option I mentioned to be able to use the interpreter.

Let us know if you have/get new info or the workaround helps!

@dixonb3
Copy link
Author

dixonb3 commented Apr 13, 2022

Hi @dalthviz and @ccordoba12 - The Connect to an existing kernel option worked! Thanks so much for your help!

@dixonb3 dixonb3 closed this as completed Apr 13, 2022
@ccordoba12
Copy link
Member

It's very strange that the connection can't be established automatically for you, but at least you have this workaround.

@ghost
Copy link

ghost commented Jul 17, 2022

I have met the same issue...
it seems that windows messed up with pythonpath

@ghost

This comment was marked as off-topic.

@adelaiden
Copy link

I had this issue as well. The workaround that @ccordoba12 provided to connect to an existing kernel works for me, but I'm interested in the solution above... @clarezei, how did you change USER_BASE and USER_SITE to those updated locations? Did you modify site.py directly?

@yuekanjiao
Copy link

I have Python and Spyder installed on my Windows 10 computer for all users, I had the same problem. Using Command Prompt - Run as administrator to install spyder-kernels solved the problem.

@emaldonadocruz
Copy link

I have this issue every time I install Spyder. So far @yuekanjiao and @ghost solutions have worked very well.

@ProfileMD92
Copy link

Hi,

I just ran into this problem too. The solution was a little simpler in my case. The Spyder documentation does not specify that you should use the python.exe file in your environment when changing the default interpreter. There is a higher level python.exe file in the miniconda folder that will produce this error.
So make sure to select
miniconda3/envs/spyder-env/python.exe
and not the first you see under
miniconda3/python.exe

@Fabien98
Copy link

I have the same issue. I've read the previous replies, and I think the problem is maybe we do not have a PYTHON installation as admin. For example, when I install a package through pip I have this warning:
Defaulting to user installation because normal site-packages is not writeable

@AJ528
Copy link

AJ528 commented Aug 29, 2023

@Fabien98 seconded. I also ran into this issue, and was able to solve it by uninstalling spyder-kernels and reinstalling as admin.

@KrisztianKaszas
Copy link

Thanks @devriea it works for me now.
@ccordoba12 maybe the solution for this ticket might be very easy, just mention in the message, that asks to activate the environment, that the pip install shall be run using an admin command prompt?

@ccordoba12
Copy link
Member

Good point @KrisztianKaszas. However, that shouldn't be necessary if we make some changes in Spyder itself.

@mrclary, could you check if the APPDATA env var is available in our consoles on Windows (both in 5.x and master)? Thanks!

@mrclary
Copy link
Contributor

mrclary commented Sep 25, 2023

On my Windows VM, for v5.4.5 and v6.0.0a2, in IPython Console and our Internal console I see APPDATA environment variable with value C:\Users\rclary\AppData\Roaming.

@ccordoba12
Copy link
Member

Thanks for checking @mrclary. Did you start Spyder in a terminal or through the Windows Start Menu?

@mrclary
Copy link
Contributor

mrclary commented Sep 26, 2023

Thanks for checking @mrclary. Did you start Spyder in a terminal or through the Windows Start Menu?

I launched both instances from the Windows Start Menu.

@ccordoba12
Copy link
Member

@dalthviz, what do you think about this one? It seems another instance of a problem we have fixed for other plugins in the past: APPDATA being not available among the env vars required by them.

Could you check if APPDATA is available in the IPython console for a stand alone Python installation?

@mrclary
Copy link
Contributor

mrclary commented Sep 26, 2023

Could you check if APPDATA is available in the IPython console for a stand alone Python installation?

@ccordoba12, what do you mean by "stand alone Python" installation? When I tested above, I used the standalone Spyder installers (downloaded from our release page on Github) and launching from the Start Menu, not a standard conda installation or dev environment.

@ccordoba12
Copy link
Member

what do you mean by "stand alone Python" installation?

I mean a Python that you download from python.org and install it in C:\Program Files

@SRattan16
Copy link

SRattan16 commented Oct 26, 2023

Hi. Thank you for sharing the resolution. I am facing the same issue on my Mac. I installed Spyder as a standalone installer. When I run pip3 list, I see Spyder kernels installed. However, when I select my python interpreter through the virtual environment, I am getting an error as the users above.

_The Python environment or installation whose interpreter is located at
/Users/myusername/.pyenv/versions/3.8.18/bin/python
doesn't have the spyder‑kernels module or the right version of it installed (>= 2.4.0 and < 2.5.0). Without this module is not possible for Spyder to create a console for you.

You can install it by activating your environment first (if necessary) and then running in a system terminal:
conda install spyder-kernels=2.4
or
pip install spyder-kernels==2.4.*_

@matejkarasek
Copy link

I have Python and Spyder installed on my Windows 10 computer for all users, I had the same problem. Using Command Prompt - Run as administrator to install spyder-kernels solved the problem.

The same solution worked for me in Windows 11 and Spyder 5.5.0.
In Windows PowerShell with admin rights, pip uninstall spyder-kernels and then pip install spyder-kernels==2.5.* did the trick.

@AbdurrahimBalta
Copy link

Hi. Thank you for sharing the resolution. I am facing the same issue on my Mac. I installed Spyder as a standalone installer. When I run pip3 list, I see Spyder kernels installed. However, when I select my python interpreter through the virtual environment, I am getting an error as the users above.

_The Python environment or installation whose interpreter is located at /Users/myusername/.pyenv/versions/3.8.18/bin/python doesn't have the spyder‑kernels module or the right version of it installed (>= 2.4.0 and < 2.5.0). Without this module is not possible for Spyder to create a console for you.

You can install it by activating your environment first (if necessary) and then running in a system terminal: conda install spyder-kernels=2.4 or pip install spyder-kernels==2.4.*_

are you solve this issue?

@ecly619
Copy link

ecly619 commented Oct 24, 2024

I have Python and Spyder installed on my Windows 10 computer for all users, I had the same problem. Using Command Prompt - Run as administrator to install spyder-kernels solved the problem.

I know this is an old thread, but I had this exact same problem and your fix solved it for me. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests