Spyder Kernels
Spyder-kernels provides the Jupyter kernels required for Spyder's console to run Python code. It enables Spyder to execute code in separate environments, ensuring isolation and flexibility for different projects. The current version is 3.1.4 and it typically releases new versions in sync with major Spyder IDE updates.
Common errors
-
ModuleNotFoundError: No module named 'spyder_kernels'
cause `spyder-kernels` is not installed in the Python environment currently selected by Spyder for its console.fixActivate the desired Python environment and install `spyder-kernels`: `pip install spyder-kernels`. Then, ensure Spyder is configured to use this environment as its interpreter. -
Kernel died, restarting. The kernel crashed while executing code in the the console. This sometimes happens because of a bug in your code or in a package you are using. For more information, please check the console or the application log.
cause This generic error often indicates an issue with the Python environment, a conflict between `spyder-kernels` and other packages (like `ipykernel`), or an incompatible `spyder-kernels` version for your Spyder IDE.fix1. Verify `spyder-kernels` compatibility with your Spyder IDE version. 2. Ensure `ipykernel` is up-to-date in the target environment. 3. Try creating a fresh environment and installing only `spyder-kernels` and your project dependencies there. -
Spyder is not starting up or console is unresponsive after environment change.
cause Often due to an outdated `spyder-kernels` in the environment, or an `ipykernel` conflict preventing the kernel from properly initializing.fixIn the problematic environment, run `pip install --upgrade spyder-kernels ipykernel`. If the issue persists, try clearing Spyder's application data (as per Spyder's documentation, usually `~/.spyder-py3` or similar), or use a fresh Python environment.
Warnings
- breaking Spyder-kernels versions are tightly coupled with Spyder IDE versions. Installing a `spyder-kernels` version incompatible with your Spyder IDE might lead to kernel startup failures or unexpected behavior.
- gotcha To run code in a specific environment from Spyder, `spyder-kernels` must be installed in *that specific environment*, not just in the environment where Spyder itself is installed.
- gotcha Mismatched or outdated `ipykernel` installations in the target environment can prevent the Spyder kernel from starting or cause it to crash.
Install
-
pip install spyder-kernels
Quickstart
import sys
print(f"Hello from Spyder kernel!\nPython version: {sys.version}")
# This code would be run directly in the Spyder IDE's console.