I tried a lot to setup projects requirements on python. Javascript with npm has package.json for everything and that days I couldn't find anything like that. But pipenv finally make this easier and it's right what I need

From now for setup my python projects I will use pipenv. It's simple and with just two files (Pipfile, Pipfile.lock). As package.json and package-lock.json in JS, pipenv create both with

python3 -m pip install --user pipenv

In case if pipenv not found

# install pipenv to ..rc profile 
python3 -m site --user-base

Then initialize your python version with

pipenv --python <version>

For example I create

pipenv --python 3.11

You will get something like this in your Pipfile

❯ cat Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.11"

Now lets install package

pipenv install requests
pipenv install -d pytest

Lest see what we have now

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
requests = "*"

[dev-packages]
pytest = "*"

[requires]
python_version = "3.11"

And that is it, easy


There are some useful commands

pipenv shell # activate venv
pipenv install <pkg_name> # to install package
pipenv install -d <pkg_name> # to install dev dependencies

For more please visit Pipenv Doc or just type pipenv -h to get brief explain what commands are available