How to use the two versions of anaconda in linux?

1

Good afternoon guys, I'm studying python for projects and I was recommended to use the anaconda package. I am a linux user (ubuntu) and therefore installed the two packages on my system. Currently in the college project, we are working with data analysis, however I can not make use of the anaconda 2 package (with version 2.7). Only version 3 is with path inscribed in the "bash.rc" script. I would like to use both versions as we are dealing with both versions of the project and would not like to use "virtual machines, or mv_env" for installation of version 2.7. So I ask is there any way? I'm looking forward to it.

PS: Do not allow the anaconda 2 package to export the path in the bash script, by first using the version of python 3.X.

    
asked by anonymous 23.07.2017 / 18:40

1 answer

1

In reality you do not need to use two versions of anaconda (and it is not related to bashrc, bashrc only indicates the location of the installation), install only one version and you can have as many environments as you need, for example, one of these versions and install. See the difference is that one comes with python 2.7 and the other one with python 3.6 as default (root). I always install 3.6.

If you installed the one that comes with pyathon 3.6 and run the command to see the (python) version, you will get:

python --version
Python 3.6.0 :: Anaconda 4.3.1 (64-bit)

Let's say you have downloaded 3.6 and need to install python 2.7 for a specific project, so do:

conda create -n py27 python=2.7

With this we create an env called py27. To enable it do:

$ source activate py27
(py27) sidon@sidon....

Note that after activation of the new environment your command prompt has changed, adding the name of the env in parentheses at the beginning "(py27)".

Now see (after the active environment) what the command to display the version gets:

python --version
Python 2.7.13 :: Continuum Analytics, Inc.

Once active, what you install (with pip, for example), will be installed in that environment.

Let's suppose that a project appears in which it is mandatory to work with python 3.4, so just do:

conda create -n py34 python=3.4

And so you have a new env. To list all your envs, do:

$ conda-env list
# conda environments:
#
autopart                 /home/sidon/anaconda3/envs/autopart
eztables                 /home/sidon/anaconda3/envs/eztables
gestauto                 /home/sidon/anaconda3/envs/gestauto
llabs                    /home/sidon/anaconda3/envs/llabs
material                 /home/sidon/anaconda3/envs/material
olist                    /home/sidon/anaconda3/envs/olist
py27                  *  /home/sidon/anaconda3/envs/py27
scrum                    /home/sidon/anaconda3/envs/scrum
root                     /home

The key indicates which env is active. To disable the current env and return to root, do:

source deactivate
    
23.07.2017 / 19:09