Using Miniconda with Conda-Forge to Avoid Anaconda Licensing Issues
Tags: conda, python, anaconda, license
Published: 2024-06-20 02:46:29

In the world of data science and Python development, Anaconda has long been a popular choice due to its comprehensive package management and environment management capabilities. However, [recent changes](https://www.anaconda.com/blog/is-conda-free) in Anaconda's licensing policies have made some organizations with more than 200 employees, look for alternatives. Who wants to pay 600USD for one license!!  An alternative is to use Miniconda, a lightweight version of Anaconda, in combination with the `conda-forge` channel. This setup provides a flexible and open-source approach to managing Python packages and environments.

In this blog post, I'll guide you through the process of setting up Miniconda with `conda-forge` to avoid Anaconda's licensing issues.

#### MINICONDA

Miniconda is a minimal installer for conda, an open-source package management system and environment management system. While Anaconda comes with a large number of pre-installed packages, Miniconda includes only conda and its dependencies. This allows users to create custom environments with just the packages they need, keeping things lightweight and manageable.

#### CONDA-FORGE

Conda-forge is a community-led collection of recipes, build infrastructure, and distributions for the `conda` package manager. The `conda-forge` channel provides a vast array of packages and is completely open-source, which helps in avoiding any potential licensing issues that might arise with using Anaconda's default repository.

#### SETTING UP 

First remove Anaconda from your system. And then follow these steps to set up Miniconda with `conda-forge`:

##### Step 1: Download and Install Miniconda

You can install `miniconda` by following the steps listed [here.](https://docs.anaconda.com/miniconda/)

##### Step 2: Initialize Conda (if not done during installation)

If you didn't initialize Miniconda during the installation, you can do it manually by running:

```bash
conda init
```

This command modifies your shell startup file (e.g., `.bashrc`, `.zshrc`, or `.bash_profile`) to enable conda in your shell sessions.

##### Step 3: Add Conda-Forge as the Default Channel

To configure `conda` to use `conda-forge` as the primary channel, run the following command:

```bash
conda config --remove channels defaults
conda config --add channels conda-forge
conda config --set channel_priority strict
```

This command removes the `defaults` channel, which is causing the license issue, adds conda-forge to the list of channels and sets it as the highest priority channel, ensuring that packages are installed from conda-forge by default.

##### Step 4: Create a New Environment

With conda-forge configured, you can create a new environment. For example, to create an environment named `myenv` with Python 3.9, you can run:

```bash
conda create -n myenv python=3.9
```

Activate the environment with:

```bash
conda activate myenv
```
Check the channels and make sure `defaults` is not mentioned. 
```bash
conda config --show channels
```

##### Step 5: Install Packages from Conda-Forge

Now you can install packages from `conda-forge`. For instance, to install NumPy and Pandas, use the following command:

```bash
conda install numpy pandas
```

Conda will resolve dependencies and install the specified packages from conda-forge.

##### Step 6: Verify Package Sources

To ensure that the packages are being installed from conda-forge, you can use the `conda list` command to list the installed packages along with their channels:

```bash
conda list
```

Look for the `channel` column in the output to verify that packages are being sourced from conda-forge.

#### CONCLUSION

Using `miniconda` with `conda-forge` is a powerful combination that allows you to avoid the licensing issues associated with Anaconda while still leveraging the full power of the `conda` package and environment management system. By following the steps outlined in this blog post, you can set up a flexible and open-source Python development environment tailored to your specific needs.

#### REFERENCES

1. Header Image: https://www.pexels.com/photo/brown-and-black-snake-on-brown-tree-branch-4063745/