Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use both Anaconda versions (2.7 & 3.5)?

I was using the Anaconda 3.5 distro in a Windows 10 machine. Due to dependencies in libraries that I want to work with, I had to have the 2.7 version installed as well.

The good news is that the libraries I needed can now work with the 2.7 version smoothly and Visual Studio 2015 automagically detected my new Python environment.

The problem comes when using the command line. Upon issuing the command

conda info --envs

I get

root                  *  C:\Users\norah\Anaconda2

i.e. a single environment (to my understanding and search so far, according to this I should see two envs listed). This means I can't use conda to acquire new packages for my Python3.5 installation, at least not at the command line as I used to since conda only refers to Python2.7. The same goes for the GUI version, Anaconda navigator (I'm not very fond of the GUI version but I tried it out).

There's also no way of launching python3 from the command line since

$python

always fires up python2.7 and issuing $python3 or $python3.5 in the command line doesn't seem to work (nor would adding the path of python3 to the system since the actual executable has the same name as python2 i.e. python.exe)

Is my system taken over by Python2.7? Is anyone here using them both smoothly and if so could you please elaborate on how to do that? Was it a "no no" move to install both versions of Anaconda?

like image 324
Lorah Attkins Avatar asked Jan 25 '17 22:01

Lorah Attkins


People also ask

Can I have two versions of Anaconda?

can I install multiple versions of Anaconda? You can but because of the answer above you don't need to and shouldn't. Instead of multiple Anaconda versions, just create multiple environments with the versions of packages you need.

Can I install Anaconda2 and Anaconda3?

You can also have both Anaconda2 and Anaconda3 installed at the same time.

Can I install both Python 2 and 3 Anaconda?

Yes, It should be alright to have both versions installed.


1 Answers

You can make Python 3.5 environment with your Anaconda 2.7:

conda create -n py35 python=3.5

Now, activate it:

activate py35

Finally you can install the desired packages:

conda install numpy

or, the whole anaconda:

conda install anaconda

The advantage of this approach is that you can also create Python 3.4 or 3.6 environments. Furthermore, you can create environments with different combinations and versions of libraries.

Actually, it makes sense to create a new environment for each larger project.

like image 176
Mike Müller Avatar answered Sep 18 '22 12:09

Mike Müller