Install Python packages from PyPi using Conda

Use Conda to manage python environments without virtualenv. How to setup and install conda packages using Pip.

  • Table of contents

Conda is a tool that can package and build python projects. We can use it as an alternative to pip and virtualenv to setup Python environments and install PyPi packages.

Install Conda

Conda or variations of it can be installed via the official website. Once install run conda -V in a shell to test the install:

conda 4.12.0

Create a new environment within a project

Conda can create virtual environments with the create command. In our examples lets create a python 3 project and write some unit tests.

mkdir p3ut
cd p3ut
conda create --name p3ut python=3.10

Conda will download packages and create a new environment called p3ut with python 3.10 installed. We can activate the environment with the activate command.

conda activate p3ut

Install packages

Lets install a package from PyPi using Conda. We can install the MailSlurp email testing library. First we need to enable pip support for Conda so we can find libraries on the Python package index.

conda config --set pip_interop_enabled True

Then install the package using the Conda linked pip command:

pip install mailslurp-client

We can verify the result by running:

conda list | grep mailslurp
> mailslurp-client          15.15.5                  pypi_0    pypi

Save packages to requirements file

Freeze your package versions to a lockfile called requirements.txt by using the Conda list command:

conda list -e > requirements.txt

The file can be used to install packages again with the conda install command:

conda install --file requirements.txt
Email and SMS Platform
Create a free account in 3 clicks