Miniconda Python is a Python distribution. You can install a version for either Python 2 or a Python 3.
Also consider using virtualenv as described here: Python Virtual Environments. These are about 250 MB in size. A Miniconda Python 3 is about 10 GBytes in size.
Download the “Linux 64-bit (bash installer)" from its download page: https://conda.io/en/latest/miniconda.html. The filename will be “Miniconda3-latest-Linux-x86_64.sh”.
There is a link on that page for the “Archive and MD5 sums for the installers”
which should point to https://repo.anaconda.com/miniconda/.
On that page search for the filename that you downloaded and find its MD5 sum.
In this case it’s
866ae9dff53ad0874e1d1a60b1ad1ef8. On the cluster check the
MD5 sum like this:
$ md5sum Miniconda3-latest-Linux-x86_64.sh 866ae9dff53ad0874e1d1a60b1ad1ef8 Miniconda3-latest-Linux-x86_64.sh
It matches OK. If it does not match do not run the installer! Contact us.
Install this into your own home directory:
$ bash Miniconda3-latest-Linux-x86_64.sh Welcome to Miniconda3 4.6 In order to continue the installation process, please review the license agreement. Please, press ENTER to continue ..... Miniconda3 will now be installed into this location: /shared/homes/xxxxxxx/miniconda3 ..... PREFIX=/shared/homes/xxxxxx/miniconda3 installing: python-3.7 installing: ca-certificates-2017.08.26-h1d4fec5_0 ... installing: conda-env-2.6.0-h36134e3_1 ... installing: libgcc-ng-7.2.0-h7cc24e2_2 ... .......
The installer will then ask you:
Do you wish the installer to initialize Miniconda3 by running conda init? [yes|no] [no] >>>
If you answer “yes” then changes will be made to the end of your
I would advise you not to do this. Answer “no” here.
(If later you wish this, then just run
conda init.) So answer “no”.
The install will then finish …
You have chosen to not have conda modify your shell scripts at all. To activate conda's base environment in your current shell session: eval "$(/shared/homes/XXXXXX/miniconda3/bin/conda shell.YOUR_SHELL_NAME hook)" To install conda's shell functions for easier access, first activate, then: conda init If you'd prefer that conda's base environment not be activated on startup, set the auto_activate_base parameter to false: conda config --set auto_activate_base false Thank you for installing Miniconda3! $
eval and the
conda init above.
Miniconda is now installed. We just need to activate it like this:
$ source miniconda3/bin/activate (base)$
Notice our prompt has changed from
(base)$, this means we are in the
base of the Conda Python environment.
Miniconda does not use the standard “pip” Python packaging manager, it uses it’s own
package manager called “conda”.
To make sure your Miniconda is at the latest version do a
conda update conda from
within the base distribution.
(base) $ conda update conda Collecting package metadata (current_repodata.json): done Solving environment: done ... The following packages will be UPDATED: cryptography 2.6.1-py37h1ba5d50_0 --> 2.7-py37h1ba5d50_0 pip 19.0.3-py37_0 --> 19.1.1-py37_0 sqlite 3.27.2-h7b6447c_0 --> 3.28.0-h7b6447c_0 urllib3 1.24.1-py37_0 --> 1.24.2-py37_0 Proceed ([y]/n)? y ....
We can activate and deactivate our Miniconda at any time like this. I have included the command for showing which python is currently active to make it clear what’s happening.
$ which python /usr/bin/python <-- This is the system Python. $ $ source miniconda3/bin/activate (base) $ (base) $ which python /shared/homes/XXXXXX/miniconda3/bin/python <-- This is your Python. (base) $ (base) $ conda deactivate $ $ which python /usr/bin/python <-- Back to the system Python. $
This is one of the most useful features of Miniconda – the ability to create several completely independent python environments. Rather than using the “base” Miniconda python we can create a new Python environment specific for what we wish to do. For instance we might have two projects; “Project A” which requires Python 3.6 and a set of Python modules and “Project B” that requires the older Python 2.7 with a different set of python modules.
Let’s create a Python virtual environment for “Project A” which will use Python 3.6. Note we will not use spaces in the directory name, spaces in file and directory names cause problems.
(base) $ conda create --name project_A python=3.6 ..... environment location: /shared/homes/XXXXXX/miniconda3/envs/project_A # # To activate this environment, use # # $ conda activate project_A # # To deactivate an active environment, use # # $ conda deactivate (base) $ conda activate project_A (project_A) $
You can run
conda list to see what modules are already installed.
conda install numpy to install the Numpy package etc.
(project_A) $ conda deactivate (base) $
Now let’s create Project B which will be a Python 2.7 environment.
(base) $ conda create --name project_B python=2.7 (project_B) (project_B) conda install imageio .... (project_A) $ conda deactivate (base) $
conda list will show you that we now have different Python packages installed
in project_A and project_B.
(base)$ conda list -n project_A (base)$ conda list -n project_B
You can remove a Miniconda environment with:
$ conda env remove -n project_B
Here we are in “Project A”. We save the current list of modules (in case we need to revert) and then update them all.
(project_A)$ conda list --export > conda_export_2019.01.10.txt (project_A)$ conda update --all
You should do this regularly within each of your Miniconda virtual environments.
Obtain help on using conda with
conda -h or `conda
$ conda config Creates a `~/.condarc` file the first time it is run. $ conda info Display information about current conda install. $ conda env list Lists your Python virtual environments. $ conda list Lists installed Python modules. $ conda list --export Save package list for future use.