Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ModuleNotFoundError for spyder-kernels module installed via pip

I am attempting to use conda to install spyder-kernels and instantiate a kernel on a remote server as per the instructions here: https://docs.spyder-ide.org/ipythonconsole.html

When I run the command python -m spyder_kernels.console I get an error:

/home/selah/anaconda3/bin/python: Error while finding module specification for 'spyder-kernels.console' (ModuleNotFoundError: No module named 'spyder-kernels')

However, I know that earlier today this command worked fine.

Any ideas about what is going on and how I might fix it?

Version info:

[selah@lothal ~]$ conda --version
conda 4.6.2
[selah@lothal ~]$ conda list | grep spyder-kernels
spyder-kernels            0.3.0                    py36_0  
[selah@lothal ~]$ find -name '*spyder-kernels*'
./anaconda3/pkgs/spyder-kernels-0.3.0-py36_0
./anaconda3/pkgs/spyder-kernels-0.3.0-py36_0.tar.bz2
./anaconda3/conda-meta/spyder-kernels-0.3.0-py36_0.json
like image 362
Selah Avatar asked Feb 05 '19 18:02

Selah


People also ask

How does Spyder connect to kernel?

Click Connect to an existing kernel from the Console menu or the IPython Console pane's “Gear” menu. Browse for or enter the path to the connection file from the previous step. If you're connecting to a local kernel, click Ok and Spyder should connect to the kernel; if a remote kernel, proceed to the final step.

What are Spyder kernels?

Package that provides Jupyter kernels for use with the consoles of Spyder, the Scientific Python Development Environment. These kernels can launched either through Spyder itself or in an independent Python session, and allow for interactive or file-based execution of Python code inside Spyder.

How does Spyder solve kernel error?

If the kernel displays a long error traceback that mentions other packages like ipython , ipykernel , jupyter_client , traitlets or pyzmq , the problem may be an out of date or incompatible version of a dependency package. To fix this, activate the environment and update the key dependencies.


1 Answers

Given your comment:

"However, I know that earlier today this command worked fine."

You may have a conda virtual environment set up which has become deactivated. Try this to see all your available conda environments:

conda env list

If there are any, you can do:

conda list -n whicheverenvyouchoose

to see if a given one has spyder_kernels installed.

If and when you find it, simply do:

conda activate whicheverenvyouchoose

If you somehow don't have any, first, create a conda virtual environment for your work with the following:

conda create -n whateveryoudcalltheenv python=x.y anaconda

where x.y is your preferred version of python.

then do:

.  activate whateveryoudcalltheenv

Now, go ahead and install your packages via:

conda install -n whateveryoudcalltheenv stuff

At that point, you should be good to go.

When you're done with working in that environment, just:

source deactivate

No need to name it.

like image 50
Chris Larson Avatar answered Oct 20 '22 13:10

Chris Larson