Setting up Miniconda on Ubuntu
Miniconda is a free minimal installer for conda. It allows you to create environments and install over 7,500 useful packages. Let’s get started setting up Miniconda in our Ubuntu.
Step 1: Download the latest shell script
Open your terminal and run the following command
$ sudo wget -c https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
Step 2: Make the downloaded script executable
Now we should provide the necessary permissions to the downloaded script to make it executable. For this, we use the chmod
command.
$ sudo chmod +x Miniconda3-latest-Linux-x86_64.sh
Step 3: Run the Miniconda installation script
Then we should run the installation script.
$ ./Miniconda3-latest-Linux-x86_64.sh
After running the above line, you would get something similar to this
Press Enter repeatedly until you reach the below line
Type yes to continue. After this, if you want to download Miniconda in a different location, specify the path after the prompt (>>>
) or if you want to just proceed with the current location, press Enter
Step 4: Activate Miniconda
Now that we have installed Miniconda, we must activate to use it. Now close the current terminal window, open a new terminal window and paste the following command
$ conda activate
If you see (base)
at the beginning of the command line, then you have successfully installed and activated Miniconda.
Step 5: Create a new environment
In order to list all the environments, enter the following
$ conda env list
By default, the base will be the only environment available. It is not advisable to download anything on base. If you want to install python while creating an environment you can specify the python=<version>
.
So let us create a new environment and install python 3.9 in it.
$ conda create -n py39 python=3.9
-n indicates the name for our new environment. In our case we have it as py39 indicating that it has python version 3.9 installed in it.
Step 6: Activate the newly created environment
We can activate env in conda using conda activate
followed by the env_name. Now paste the following command to activate the newly created environment.
$ conda activate py39
If you see (py39)
it at the beginning, then you are good to go.
Step 7: Deactivate
If you are done with your work and you want to deactivate your environment, enter the below command in your terminal
$ conda deactivate
You have successfully installed Miniconda on your PC. Now all that is left to do is to activate the environment of your choice and code away!!