How to Use Poetry with Conda for Package Management
How to Use Poetry with Conda for Package Management
Source
Summarised from How to Use Poetry with Conda for Package Management on a Specific Python Version (Micheleen Harris)
Overview
Conda (from an Anaconda Distribution) and Poetry can be used for Python package management, however Poetry additionally provides a mechanism to build a Python package.
Poetry is more modern and provides many more tools out-of-the-box for better reproducibility and package builds.
It is not common to use both together, however if we want a specific Python version we can get that with Conda and then manage our dependencies and package with Poetry.
Instructions
-
Install poetry by following this Installation guide.
-
Configure poetry to use conda environment.
poetry config virtualenvs.path $CONDA_ENV_PATH poetry config virtualenvs.create false
where CONDA_ENV_PATH is the path to the base envs folder (e.g., /home/myuser/miniconda3/envs).
Do Not make the mistake I did and export CONDA_ENV_PATH in your bash profile...
-
Create a Python 3.x conda environment (here called awesomeness).
conda create -n awesomeness python=3.11
-
Activate the conda environment.
conda activate awesomeness
From this point on only use Poetry to manage packages in your project.