We already discussed the need of pyenv (managing python versions) and pipenv (managing dependencies).
In this post, I will show you an alternative to pipenv, called poetry. Its a quite new library.
Given you read the article on pyenv pipenv combination you can just install the version of python you want to play around with:
pyenv install 3.9.2
pyenv local 3.9.2
and than you just install inside your pyenv environment the poetry dependency globally. This is actually not the suggested way of doing it, but I think its totally fine, as we want to use this particular version of python here.
After you set the python version, you can install now poetry using
pip3 install poetry
For your dependency management, you need a new type of file. Its named pyproject.toml - I will give you some example of it:
[tool.poetry]
name = "poetry-example"
version = "0.1.0"
description = ""
authors = ["Darius Murawski <darius@murawski.blog>"]
[tool.poetry.dependencies]
python = "3.9"
pandas = "^1.3.5"
[tool.poetry.dev-dependencies]
pytest = "*"
The first block describe some meta data of the dependencies like the author, version end descriptions. The second block defines your general dependencies and the lowest one the dev dependencies.
To get your dependencies up and running, just run
poetry install
and everything will be installed. Note that packages will be fetched in parallel, making it (a lot) faster than with pipenv, where every package is fetched sequentially.