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: Allows you to create custom environments with the specific versions of Python and packages you need for your project.
- Package Control: Facilitates the installation and management of packages and their dependencies.
- Compatibility: Compatible with most Python packages and environments, which is ideal for projects on Raspberry Pi.
How to Install Miniconda on Raspberry Pi
Before starting, 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, we first visit the official Miniconda page to get the download link corresponding to the Raspberry Pi’s ARM architecture.
We must choose the version for Linux ARMv7 if we use 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 to 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 make sure 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
We follow the on-screen instructions, accept the license terms, and choose the installation location, which by default will be ~/miniconda3.
After installation, the script will ask us 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 mi_entorno python=3.9
Here, my_environment is the name of your environment and python=3.9 specifies the Python version. You can adjust this according to your needs.
Activate the Environment
To activate the newly created environment:
conda activate mi_entorno
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 mi_entorno —all
