“conda” a Python package manager, allows you to create “environments” which are sets of packages that you can modify. It does this by installing them in your home area. This page will guide you through loading conda and then creating and modifying environments so you can install and use whatever Python packages you need.
Following libraries have been installed using conda in virtualenv of Anaconda Python 3 :
numpy, scipy, ipython, cython, matplotlib, pandas, scikit-learn, scrapy, nltk, pattern, gensim, seaborn, bokeh, basemap
Anaconda version 4.5.4
is available for both Python 2 and 3 and can be loaded through provided module files:
export PATH=”/opt/anaconda3/bin:$PATH”
Using conda Environments
There are a small number of environments provided for everyone to use, these are the default root
and python2
environments as well as various versions of Anaconda for Python 2 and Python 3.
Once the conda module is loaded you have to load or create the desired conda environments. For the documentation on conda environments see the conda documentation.
You can load a conda environment with:
source activate /opt/anaconda3
where python2
is the name of the environment, and unload one with:
source deactivate
It is possible to list all the available environments with:
conda env list
Provided system-wide are a set of anaconda environments, these will be installed with the anaconda version number in the environment name, and never modified. They will therefore provide a static base for derivative environments or for using directly.
Creating an Environment
Every user can create their own environments, and packages shared with the system-wide environments will not be reinstalled or copied to your file store, they will be symlinked
, this reduces the space you need in your /home
directory to install many different Python environments.
To create a clean environment with just Python 2 and numpy you can run:
conda create -n mynumpy python=2.7 numpy
This will download the latest release of Python 2.7 and numpy, and create an environment named mynumpy
.
Any version of Python or list of packages can be provided:
conda create -n myscience python=3.5 numpy=1.8.1 scipy
If you wish to modify an existing environment, such as one of the anaconda installations, you can clone
that environment:
conda create --clone anaconda3-4.2.0 -n myexperiment
This will create an environment called myexperiment
which has all the anaconda 4.2.0 packages installed with Python 3.
Installing Packages Inside an Environment
Once you have created your own environment you can install additional packages or different versions of packages into it. There are two methods for doing this, conda
and pip
, if a package is available through conda it is strongly recommended that you use conda to install packages. You can search for packages using conda:
conda search pandas
then install the package using:
conda install pandas
if you are not in your environment you will get a permission denied error when trying to install packages, if this happens, create or activate an environment you own.
If a package is not available through conda you can search for and install it using pip, i.e.:
pip search colormath
pip install colormath
For any queries, raise a ticket in the helpdesk or please contact System Administrator, #103,SERC. |