Python distribution and dependency management can be a bit of a nightmare1 , thus it is prudent to unambiguously specify what a project requires.
The pyenv
2 Simple Python Version Management: pyenv project provides global (system-level) and local (project-level) python version control.
View installed versions3 Lists all Python versions known to pyenv, and shows an asterisk next to the currently active version.:
pyenv versions
View and install available distributions using pyenv install
4 Install a Python version.
pyenv install --list
pyenv install 3.8.1
Set a global default distribution5 Sets the global version of Python to be used in all shells.:
pyenv global 3.8.1
Set a project-level distribution6 Sets a local application-specific Python version.:
pyenv local 3.8.1
The pipenv
7 Pipenv: Python Development Workflow for Humans. project provides project-level package installation à la npm, renv, etc.
Install/uninstall packages works as it does with pip
, just with pipenv
instead:
pip install pandas
pip uninstall pandas
Launch a shell with the local environment:
pipenv shell
Run a command in the local virtual environment:
pipenv run <command>
pipenv run juptyer notebook
pipenv run python script.py