
Miniconda is a lightweight version of Anaconda designed for Python-based machine learning, data science, and software development. Unlike the full Anaconda distribution, it includes only Conda—the package and environment manager—along with a few essential utilities, making it ideal for systems with limited storage or users who prefer to customize their environments from scratch. For Ubuntu 24.04 users, Miniconda is especially helpful for creating isolated Python environments, managing dependencies efficiently, and optimizing system resources on both servers and local machines.
This article explains how to install Miniconda on Ubuntu 24.04 and set up Conda virtual environments to manage Python packages on the server. If you're looking for instructions for a different version, check out our article on Install Miniconda on Ubuntu 22.04.
Before you begin:
Miniconda is not available in the default package repositories on Ubuntu. Follow the steps below to download the latest installation script and install Miniconda on your server.
Switch to your user's home directory.
Create a new miniconda3 project directory.
Visit the Miniconda releases page and download the latest Miniconda3 installation script.
Run the miniconda.sh script using Bash to install Miniconda.
The above command installs Miniconda and creates a new base Conda environment for Python packages, dependencies, and libraries on your server.
Activate Conda.
Verify that your shell prompt changes to the base Conda environment.
Initialize Conda to add new configurations in your shell environment.
Reload your shell configuration to activate Conda.
View the installed Conda version.
Your output should be similar to the one below.
View information about the active Conda environment, Python version, and channels.
Output:
Conda environments allow you to isolate and manage specific packages, dependencies, and versions required in your projects. On your server, Conda supports one active environment at a time. Activating a new environment automatically deactivates the active environment. Follow the steps below to create and activate Conda environments to run specific Python packages on your server.
Create a new myenv Conda environment.
Verify the myenv path, enter y, and press Enter when prompted to create the Conda environment.
Activate the myenv Conda environment.
Verify that your Conda environment changes from (base) to (myenv).
Install specific packages in the myenv environment. For example, install Python 3.12, numpy and pandas to use in your project.
Enter y and press Enter when prompted to install the packages.
Create another myenv-2 Conda environment.
List all available Conda environments on your server.
Output:
Deactivate the active myenv Conda environment.
The above command deactivates the active myenv environment and reactivates the base environment as the active environment.
Jupyter Notebook is an open-source interactive computing application that uses computational notebooks to execute code and run various applications. Jupyter Notebook is typically accessed in a web browser, but can also run in a terminal session using nbconvert and jupyter console commands. Follow the steps below to install the Jupyter Notebook package and run a notebook in your active Conda environment.
Install the latest jupyter package version in your environment.
Enter y and press Enter when prompted to install the package.
View all installed packages in the Conda environment and verify that the new jupyter package is available.
Your output should be similar to the one below.
Create a new hello.ipynb example notebook using a text editor such as nano.
Add the following contents to the hello.ipynb file.
Save and close the file.
The above file creates a new notebook with two cells, a code cell and a raw cell using the Python version 3.10.12 as the kernel. The code cell creates a msg variable that prints a Greetings from Vultr! message to the standard output (stdout).
Run the hello.ipynb notebook to execute all code cells and save the output to a hello.nbconvert.ipynb notebook in your environment.
Output:
View the hello.nbconvert.ipynb file contents and verify that it includes a Greetings from Vultr! message in the outputs section.
Output:
You have installed Miniconda on Ubuntu 24.04 and created Conda environments to manage specific packages on the server. You can create multiple Conda environments to isolate specific projects, install Python packages and libraries to run on your server. For more information and configuration options, visit the Miniconda documentation.
0 Comments
Be the first to comment and share your perspective with the community.