Installation Poetry on Distant lab

Complexity Explained

Poetry functions is a standalone tool that leverages the Python environment as its foundation. Consequently, Poetry must be installed on the base Python system. However, modifying the Python installation directly on shared systems, such as laboratory setups, is risky, as libraries can potentially be altered by other users. Therefore, the recommended approach is to create a dedicated virtual environment for Poetry’s installation.

To set up Poetry in a virtual environment, follow these steps:

1
2
3
foo@bar:~$ python3 -m venv .poetry 
foo@bar:~$ source .poetry/bin/activate
(.poetry) foo@bar:~$ python -m pip install poetry

Once Poetry is installed, deactivate the virtual environment: (this step is mandatory because otherwise you would overwrite poetry installation with some package)

1
(.poetry) foo@bar:~$ deactivate

At this point, Poetry is ready for use, enabling you to manage dependencies and installations as needed.

Poetry can have some issue with local package when updating. it is advised to run :

1
2
poetry remove <package>
poetry add --path ../<link_to_local_package> --develop

In order to regain control over poetry local

Note: It is important to distinguish between this dedicated virtual environment for Poetry and the typical project-specific virtual environments (e.g., .venv).


Installation Poetry on Distant lab
https://eymeric65.github.io/p/014519b650ae451bb4db75ee90cd7385/
Author
Eymeric Chauchat
Posted on
October 16, 2024
Licensed under