Easy Way to switch Environments in Spyder?

68,887 views
Skip to first unread message

Sayth Renshaw

unread,
Oct 26, 2015, 9:30:21 AM10/26/15
to spyder
Hi all

Is there an easy way to switch between python virtual environments in spyder? 

I am on windows and using anaconda with python 3.4, I do create envs in both python2 and python3 and wondering if there was an obvious way to achieve this?

Cheers

Sayth

Sayth Renshaw

unread,
Oct 27, 2015, 8:11:50 AM10/27/15
to spyder
I can see in preferences under console there is an option for the python interpreter but is this for the whole project?

Sayth

David Verelst

unread,
Oct 28, 2015, 6:43:28 PM10/28/15
to spyder
The interpreter you can chose only affects the consoles you open from within Spyder (but not the internal Spyder console). You can change the environment in which Spyder runs by re-launching from another environment. I am not a regular anaconda user, but I assume you can install Spyder in each of your environments if you want to have Spyder running from within that environment specifically. An alternative method is to activate the environment, and run Spyder directly from its sources with the bootstrap method (first browse to the Spyder git repository root directory): ```python bootstrap.py```.

Regards,
David

--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.
Visit this group at http://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.

Michael Currin

unread,
Dec 31, 2017, 7:34:01 AM12/31/17
to spyder
I don't know about switching versions, other than installing both spyder (for Python2) and spyder3 (for Python3) on your system. In my Linux package manager, I have the optional to install them independently.

I don't know if this helps, but I found a way to effectively activate a virtualenv within Spyder. Then I could run scripts inside spyder and do imports from the iPython console.

For example, in the command-line, if you have virtual environment with sqlobject installed in it...

$ virtualenv my_project_virtualenv
$ source my_project_virtualenv/bin/activate
$ pip install sqlobject

Then, in Spyder 
  1. select Tools
  2. select Python Path Manager
  3. add path in this form /home/michael/path/to/my_project_virtualenv/lib/python2.7/site-packages
  4. ipython console
    • import sqlobject
If that doesn't work straight away, maybe open a new iPython console, or restart spyder itself.

You can add multiple environments added like that, though I guess there is a problem switching between them since they are all active. And they might each have different versions of the same package.

Pupilo Om

unread,
May 25, 2018, 4:40:02 PM5/25/18
to spyder
On Anaconda promt/ Command promt:

spyder activate your_env

This will open Spyder running under your_env

Hope this helps
Tomas

Gastón García González

unread,
Apr 4, 2020, 12:33:23 PM4/4/20
to spyder
Hi,

in conda prompt:

  • conda activate env_name

  • conda install spyder

  • spyder
then you have running spyder in your environment. 

Derek

unread,
Apr 5, 2020, 3:06:05 PM4/5/20
to spyd...@googlegroups.com
Is there an easier way to do this without having to install Spyder into every virtual environment?

--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.

Michael Currin

unread,
Apr 5, 2020, 9:21:43 PM4/5/20
to spyd...@googlegroups.com
Install Spyder in an environment created by pip and activated using source command rather than command. The reason being when you switch conda envs, spyder becomes unavailable.

Then start spyder using that env activated. Or add the env's site packages to your PATH. And make sure you start this and not a conda installed spyder.

Now inside Spyder, update Python Path Manager
Add paths for your conda envs. Based on my earlier answer above in 2017.

Unfortunately this will give issues where two different versions of a package are in different envs and the one at the top of the Python paths list is used.



Regards,
Michael


Sent from mobile

You received this message because you are subscribed to a topic in the Google Groups "spyder" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/spyderlib/NWGlu7r7xxo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to spyderlib+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/spyderlib/CAF1Wu3NgDOzQOMKp_YwmosSNOyu_dUj3Xpw%2Bycsd%2BLhAvzXEuQ%40mail.gmail.com.

Derek

unread,
Apr 29, 2020, 3:41:49 PM4/29/20
to spyd...@googlegroups.com
"Install Spyder in an environment created by pip" - yes, I have one copy installed that way, but I have dozens of other virtual environments; are you saying I need to install dozens of copies of Spyder - that's just not not workable.  I am sure I am misunderstanding something here.  I am looking for a way to install one copy of Spyder and for it to understand what virtual environment my **current** project is running in, and be able to read/access all the packages installed in *that* environment (so that, for example, PEP8 does not complain about missing packages).

Carlos Córdoba

unread,
Apr 29, 2020, 3:43:23 PM4/29/20
to spyd...@googlegroups.com
Hi,

Please read our guide about how to deal with a single Spyder and multiple envs to understand how to work that way:

https://github.com/spyder-ide/spyder/wiki/Working-with-packages-and-environments-in-Spyder


Cheers,
Carlos

El 29/04/20 a las 12:27 a. m., Derek escribió:

Derek

unread,
May 2, 2020, 11:22:11 AM5/2/20
to spyd...@googlegroups.com
Hi

I followed that link and am trying "The Modular Approach", which says:

conda install spyder-kernels=0.*

However, when I do that, conda seems unable to process it; it spends a long time processing and the reports:

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

followed by a very, very long list of packages.

This seems not very straightforward?





Reply all
Reply to author
Forward
0 new messages