How to Install Miniconda on Debian 12

Estimated reading: 3 minutes 73 views

Introduction

Miniconda is a minimal installer for the Anaconda distribution that includes only conda, Python, and a few essential packages. It’s lightweight, fast to install, and allows users to manage environments and packages without the bulk of Anaconda. In this guide, you’ll learn how to install Miniconda on Debian 12, create and manage environments, and set up a basic Flask application using Conda.


Prerequisites

Before proceeding, ensure you have:

  • A system running Debian 12

  • A non-root user with sudo privileges

  • Access to the terminal/SSH


Step 1: Download and Install Miniconda

First, download the latest Miniconda installer script:

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

Run the installer script:

bash Miniconda3-latest-Linux-x86_64.sh

Follow the prompts:

  • Press Enter to scroll through the license

  • Type yes to accept

  • Press Enter to confirm the default install location

  • Type yes to initialize Miniconda

Reload your shell to activate the installation:

source ~/.bashrc # for Bash users
# or
source ~/.zshrc # for ZSH users

Check that Conda is working:

conda --version


conda info


Step 2: Create a New Conda Environment

To create a new environment named cenv, use:

conda create -n cenv

Activate the environment:

conda activate cenv

Install necessary packages (e.g., Python 3.12, BeautifulSoup4, docutils):

conda install python=3.12 beautifulsoup4 docutils

To deactivate the environment:

conda deactivate

You can also create an environment and install packages in one line:

conda create -n cent python=3.12 beautifulsoup4 docutils

Step 3: Create Environment Using a YAML File

Create a file named environment.yml:

nano environment.yml

Add the following content:

name: myproject
dependencies:
- python=3.12
- pip
- flask

Create the environment:

conda env create -f environment.yml

Activate it:

conda activate myproject

Step 4: List Environments and Packages

To list all environments:

conda env list

To list installed packages in a specific environment:

conda list -n myproject
# or
conda list -n cenv

Step 5: Remove Packages and Environments

To remove a specific package:

conda remove -n myproject pip

To remove an entire environment:

conda remove -n myproject --all

Confirm the environment is removed:

conda env list

Step 6: Set Up Flask Application Using Conda

Activate your environment:

conda activate cenv

Install Flask and pip:

conda install python=3.12 pip flask

Create your project directory and enter it:

mkdir -p ~/flask && cd ~/flask

Create the Flask app:

nano myapp.py

Paste the following code:

#myapp
from flask import Flask, render_template # importing the render_template function

app = Flask(__name__)
# route to index page
@app.route("/")
def hello():
return render_template('index.html')

if __name__ == ' __main__':
app.run(debug=True)

Create the HTML template:

mkdir templates
nano templates/index.html

Add this HTML:

<html>
<body>
<h1><center>Hello Flask within Miniconda!</center></h1>
</body>
</html>

Run the Flask app:

flask --app myapp run

In another terminal, test the app:

curl http://localhost:5000/


Conclusion

You have successfully installed Miniconda on Debian 12 and learned how to:

  • Create and manage environments with Conda

  • Install packages

  • Create environments from YAML files

  • Remove environments and packages

  • Set up a basic Flask web app

Miniconda makes Python project management efficient and consistent across teams. For production or collaborative development, using YAML files ensures reproducibility and ease of deployment.

Share this Doc

How to Install Miniconda on Debian 12

Or copy link

CONTENTS