How to Change Python Version in Anaconda Spyder

Spyder, spyder-kernels and python version compatibilities?

(Spyder maintainer here) You said

From random blogs and questions on StackOverflow I know that Spyder >= 4 requires Python >= 3

This is incorrect. Spyder 4.1.5 is compatible with Python 2.7. We drop support for Python 2.7 in our 4.2.0 version, released in November 2020.

and spyder-kernels at least 1.9 up (maybe lower, haven't tried all...)

Here you can find the list of spyder-kernels versions that are necessary for different Spyder ones. That needs to be updated for Spyder 5, but we will do that soon.

For Python 2.7 I can only go as far as Spyder 3, but I can't find the proper Spyer-kernels to install.

There's a misunderstanding here. You can still use Spyder 5 (which only supports Python 3) and run your Python 2 code in a different environment with the latest spyder-kernels, which still supports Python 2.7.

For that, first you need to run the following commands

conda create -n py27 python=2.7
conda activate py27
pip install spyder-kernels

It's necessary to use pip to install spyder-kernels because Anaconda and Conda-forge stopped creating packages for Python 2 a long time ago.

Then you need to connect Spyder to that env by following these instructions.

Which spyder-kernels do I need for installing spyder3 in a python 2.7 environment?

You don't need to do that, according to what I mentioned above.

Switch between spyder for python 2 and 3

Spyder is launched from the environment that you're using.

So if you want to use python 3 in Spyder then you activate python34 (or whatever you named the environment with Python 3) then run spyder.

If you want to use python 2 in Spyder then you deactivate the python3 environment (or activate an environment in which you installed Python 2) then run spyder.

I do not believe that you can change environments once Spyder is launched.

N.B. you may need to install Spyder in each environment, depending on your set up, by first activating the environment then using conda install spyder.

how to update spyder on anaconda

To expand on juanpa.arrivillaga's comment:

If you want to update Spyder in the root environment, then conda update spyder
works for me.

If you want to update Spyder for a virtual environment you have created (e.g., for a different version of Python), then conda update -n $ENV_NAME spyder where $ENV_NAME is your environment name.

EDIT: In case conda update spyder isn't working, this post indicates you might need to run conda update anaconda before updating spyder. Also note that you can specify an exact spyder version if you want.



Related Topics



Leave a reply



Submit