Miniconda is a lightweight distribution of Conda, a widely used environment and package manager in the Python ecosystem.
Raspberry Pi has limited resources compared to a desktop PC, so a lightweight solution like Miniconda is ideal to avoid system overload.
Unlike Anaconda, which includes a large number of default packages and tools, Miniconda offers a basic installation that allows you to create and manage Conda environments and then install only the packages you need.
The advantages of using Miniconda are:
- Lightweight: Miniconda takes up less disk space because it only includes the essentials to get started.
- Flexibility: It allows you to create custom environments with the specific versions of Python and packages you need for your project.
- Package Control: It simplifies the installation and management of packages and their dependencies.
- Compatibility: It is compatible with most Python packages and environments, which is ideal for projects on Raspberry Pi.
How to install Miniconda on Raspberry Pi
Before you start, make sure you have a Raspberry Pi with Raspberry Pi OS installed and updated. You can update your system with the following commands:
sudo apt update
sudo apt upgrade
Now, to download Miniconda, first visit the official Miniconda page to get the download link corresponding to the ARM architecture of the Raspberry Pi.
We need to choose the version for Linux ARMv7 if we are using a Raspberry Pi 2 or 3, or ARMv8 for Raspberry Pi 4 and later.
Once we have the correct link, we use wget
to download the installer on the Raspberry Pi. For example, for a Raspberry Pi 4 (ARMv8), the command would be:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-armv8l.sh
Then, before running the installer, we need to ensure that the file has execution permissions with the following command:
chmod +x Miniconda3-latest-Linux-armv8l.sh
We proceed to start the installation process by running:
./Miniconda3-latest-Linux-armv8l.sh
Follow the on-screen instructions, accept the license terms, and choose the installation location, which by default will be ~/miniconda3
.
After the installation, the script will ask if we want to initialize Miniconda. We accept so that conda
is added to our PATH. To apply the changes, we close and reopen the terminal or run:
source ~/.bashrc
Finally, to verify that Miniconda has been installed correctly, we run:
conda --version
This should display the installed version of Conda.
How to use Miniconda
Once Miniconda is installed, you can start managing your environments and packages.
Create a new environment
You can create a new environment with a specific version of Python and packages:
conda create --name my_environment python=3.9
Here, my_environment
is the name of your environment and python=3.9
specifies the version of Python. You can adjust this according to your needs.
Activate the environment
To activate the newly created environment:
conda activate my_environment
Install packages
With the environment activated, you can install packages using Conda:
conda install numpy pandas
Deactivate the environment
When you finish working, you can deactivate the environment with:
conda deactivate
Remove an environment
If you no longer need an environment, you can remove it with:
conda remove --name my_environment --all