Saturday, July 23, 2016

Managing Python Environment using Anaconda

Previously, we discussed that you could manage multiple versions of Python runtime environment on Linux systems using python-virtualenv. This post is a note on how we may manage Python runtime environment using Anaconda. Anaconda is a cross-platform tool, and runs on Windows, Mac OS X, and Linux.

Below are steps tested on a Windows 10 system.
  1. Download Anaconda package and install it.
  2. You can now see that Python is installed
    
    C:\Users\DemoUser>python --version
    Python 3.5.2 :: Anaconda 4.1.1 (64-bit)

  3. See this page for how to manage different version of Python environment. Below shows how we may bring Python up-to-date.
    
    C:\Users\DemoUser>conda update python
    Fetching package metadata .......
    # All requested packages already installed.
    # packages in environment at C:\Anaconda3:
    # python 3.5.2
    

Of course, we can do more with Anaconda, such as, manage Python packages. Below shows that we can install Gensim and all its dependencies in one single step.


C:\Users\DemoUser>conda install -y gensim
Fetching package metadata .......
Solving package specifications: ..........

Package plan for installation in environment C:\Anaconda3:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    bz2file-0.98               |           py35_0           6 KB
    conda-env-2.5.2            |           py35_0          67 KB
    conda-4.1.9                |           py35_0         247 KB
    smart_open-1.3.3           |           py35_0          28 KB
    gensim-0.12.4              |      np111py35_0         2.2 MB
    ------------------------------------------------------------
                                           Total:         2.6 MB

The following NEW packages will be INSTALLED:

    bz2file:    0.98-py35_0
    gensim:     0.12.4-np111py35_0
    smart_open: 1.3.3-py35_0

The following packages will be UPDATED:

    conda:      4.1.6-py35_0       --> 4.1.9-py35_0
    conda-env:  2.5.1-py35_0       --> 2.5.2-py35_0

Fetching packages ...
bz2file-0.98-p 100% |###############################| Time: 0:00:00  95.70 kB/s
conda-env-2.5. 100% |###############################| Time: 0:00:00 245.29 kB/s
conda-4.1.9-py 100% |###############################| Time: 0:00:01 155.70 kB/s
smart_open-1.3 100% |###############################| Time: 0:00:00 205.54 kB/s
gensim-0.12.4- 100% |###############################| Time: 0:00:15 150.04 kB/s
Extracting packages ...
[      COMPLETE      ]|##################################################| 100%
Unlinking packages ...
[      COMPLETE      ]|##################################################| 100%
Linking packages ...
[      COMPLETE      ]|##################################################| 100%
C:\Users\DemoUser>


Note that in the above we install packages for DemoUser. To install packages system-wide, we need to be elevated to system administrator.

1 comment: