If you have some Python scripts which rely on some packages that need a different version other than the version your Python Spyder uses, you can simply use Python Virtualenv to run Spyder IDE .

This will save you a lot of headache and you can simply continue with your development projects.

This tutorial will guide you through how to run Spyder Anaconda IDE from Python’s Virtualenv

  1. Install the versions of Python you want to use. In my case, Python 2.7 and Python 3.5 (Python 3.5 is the default my Spyder uses so i will only install 2.7)
  2. Set the appropriate environment Variables.
  3. Note the User Environment Variables take precedence over the System variables
  4. Create Virtualenv environment for Spyder in my case I created it for Python 2.7  by calling from command prompt:
  5. conda create -n myenv python=3.4 anaconda

     

    This will create virtual environment to virtualenv. To activate it :

    source activate myenv

     

    And now to run Spyder with Python 3.4 just type:

    spyder

     

  6. the above instruction is from stackoverflow here and it is further explained below:
  7. Replacing Python 3.4 with Python 2.7  (or the python version you want to install) and give it appropriate name , replacing myenv with the name you want, eg spyderenv
  8. Once it is installed , in my case (\Users\adaba\Anaconda3\envs\spydervirenv\Scripts>) navigate to that source , as in the directory path, and activate the virtualenv, by calling activate and then the name of your virtualenv , hence “activate spyderenv”
  9. virtualenv spyder
  10. You can double-check which python was used for the spyder virtual environment by typing python -V at the command prompt (in the activated virtualenv)
  11. You can install any modules or packages you want by calling pip install inside of your activated virtualenv (spyderenv)
  12. You can finally launch spyder from the virtualevn with the Python version you want by simply typing spyder at the command prompt
  13. You can also access it from your windows All Programs in the Start Menu virtualenv in all programs
  14. And if you want to check all available virtualenvs you have created, you can list all discoverable environments with `conda info –envs` at the command prompt conda-info-env
  15. The other option will be to “have to path out to python.exe, but it seems that in Linux/OS X you just path to the folder. Example: Windows:  virtualenv -p <PATH TO PYTHON.EXE> venv
    virtualenv -p <PATH TO PYTHON.EXE> venv

     

    Creates a virtual environment in subfolder “venv” in current directory.” 

    This is courtesy of the stackoverflow comment by “Mike Davlantes” here

  16. Hope this helps.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *