0

I installed latest version of Anaconda that gave me Python 3.6.0. Now i need to do following ( Platform WINDOWS )

  • Create another environment with python 2.7
  • Always set that environment as my default environment.
  • install Spyder and several other packages for python 2.7 that are installed into my root environment for python 3.6.0 ( NOT MANUALLY ).

I tried creating another environment using

Conda create --name env-python-2.7 python=2.7

But this does not install several packages that are by default installed with my root environment.

Also when i launch Spyder it is always using my root environment which is pointing to Python 3.6.0

ATHER
  • 3,254
  • 5
  • 40
  • 63
  • I do this all the time for my colleagues and I always refer to [this post](http://stackoverflow.com/questions/30492623/using-both-python-2-x-and-python-3-x-in-ipython-notebook) for the solution. Only difference is that it doesn't set that environment as default. – Ébe Isaac Apr 29 '17 at 07:17
  • At this point in time you should *not* use python 2.7 as your default environment anymore if you are starting with Python. Maintenance for Python 2.7 will be stopped in 2020. – Roland Smith Apr 29 '17 at 08:46
  • @RolandSmith I very much agree with you about not setting 2.7 as default but sadly some packages are yet to be ported to 3.x (like the [Python-Weka-Wrapper](https://pypi.python.org/pypi/python-weka-wrapper)). – Ébe Isaac Apr 29 '17 at 09:21
  • @ÉbeIsaac There are other machine learning packages (like [keras](https://keras.io/)) that *do* work for Python 3 and as a bonus do not require Java. :-) If package authors are not working on Python 3 support now, either you have to step up and help porting or you have to go looking for alternatives. – Roland Smith Apr 29 '17 at 09:26
  • @RolandSmith: Guess you're right; it is for that reason I completely moved to [SciKit-Learn](http://scikit-learn.org/) for my current project. I needed that wrapper to reproduce the results of my last paper. I suppose I ought to port my code the SciKit equivalent in future. – Ébe Isaac Apr 29 '17 at 09:49
  • @RolandSmith Guess you're right; it is for that reason I moved completely to SciKit learn. Only thing is that my previous paper required the wrapper and use it only to reproduce the results when asked. – Ébe Isaac Apr 29 '17 at 11:19

1 Answers1

0

You need to do the following:

conda create -n env-python-2.7 python=2.7 anaconda
conda install -n env-python-2.7 spyder
conda install -n env-python-2.7 your_other_packages...
activate env-python-2.7
spyder

You always need to do 'activate env-python-2.7' first before you can invoke the Python 2.7 env and the packages you installed there.

Allen Qin
  • 19,507
  • 8
  • 51
  • 67
  • That's pretty straight forward but note that the OP also wanted to make that environment as the default one -- that part is not inluded in your answer. – Ébe Isaac Apr 29 '17 at 07:19
  • I don't think that's straight forward. Maybe try to install Anaconda 2.7 as the default root env and create a Python 3.5 virtual env instead? – Allen Qin Apr 29 '17 at 07:28
  • You're right about that (I did the same thing for people who prefer 2.7) and that's what prevented me from posting and answer too. However, I have a feeling that it is not entirely not possible. – Ébe Isaac Apr 29 '17 at 07:30
  • Allen Thanks for your answer, that helped. But i really like to automate line# 3. Is there a way to get the names of the packages from specific environment and re-install them in a new env with speciifc python version ? I think when we do "pip list" that looks on the root environment. – ATHER Apr 29 '17 at 21:54
  • You can get the list of packages from a virtual env by running 'conda list -n your_virtual_env'. – Allen Qin Apr 29 '17 at 22:06