Miniconda - How to set up a basic Conda python environment in Fedora

Intro

Conda is a popular package, dependency and environment management for any language (Python, R, Ruby, Lua, Scala, Java, JavaScript, C/ C++, FORTRAN). With this package manager it’s really easy to set up a python virtual environment. In this post, I’ll show how to set up a basic Conda (Miniconda) Python virtual environment in Fedora.

Installation

Assuming you already have a running machine with Fedora, or a similar distro, you can download the installer package running the following command:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

Now you should run the installer. In order to do that, you might need to make the file executable:

chmod +x Miniconda3-latest-Linux-x86_64.sh

Now you can run the installer. From the folder where you have downloaded the file run the following command:

./Miniconda3-latest-Linux-x86_64.sh

Press enter to review the license (then press space to read the rest of it). Once read, accept it by typing:

Do you accept the license terms? [yes|no]
[no] >>> yes

Re-press enter to accept the default installation location (or change it accordingly). The installer will also ask you whether to initialise Miniconda3 in your user’s bashrc (.bashrc) file. I.e., it will set the default python environment to ~/miniconda3/ (if that’s the chosen installation location) everytime a console is opened. I prefer to apply this change manually everytime, to make it easier to choose which python environment I am going to use. Hence, I press no.

Do you wish the installer to initialize Miniconda3
in your /root/.bashrc ? [yes|no]
[no] >>> no

Done! You successfully installed the conda package manager. Now, to actually make use of the python environment, run the following command:

source ~/miniconda3/bin/activate

This command will add a (base) string before you command prompt, meaning your python environment has been initialised. Typing the following command will provide you with the installed Python version:

python -V

In my case:

Python 3.7.1

P.S. For some reason the Docker version of Fedora doesn’t come with bzip2 installed, therefore you might need to install it before running the installer:

sudo dnf install bzip2

Any comments? Let me know!

comments powered by Disqus