Python Conda

conda is similar to venv.

conda create --name myenv
conda activate myenv
conda install --file requirements.txt

Important often i.e if you are using someone else’s code, you have to specify in “create” and a .yml file like his:

conda env create -f requirements.yml

When using both conda and pip, the best practice is to follow this order:

  1. Conda first conda install <package>
  2. If conda doesn’t find a package then pip install <package>

To get the latest versions of most data science tools, add the conda-forge channel:

conda config --add channels conda-forge
conda config --set channel_priority strict

Previous solves the error PackagesNotFoundError for packages like absl-py.

Using Conda with Google Colab: a version of conda can also be activate in Google Colab

!pip install -q condacolab
import condacolab
condacolab.install()
 
# Use python 3.10 without environment.yml
!mamba install python=3.10 -c conda-forge --yes
 
# Or with environment.yml
!mamba env update -n base -f environment.yml

When using the google colab version, you are restricted to use (and update) che base environment called “base”.

Conda in VSCodium:

  • Control + Shift + P > Select Environment > select conda