Python Setup
Table of Contents:
- Pyenv
- Installing Pyenv
- Installing Pyenv with Debian
- Poetry
- Poetry Installation
Pyenv
Tool used to manage multiple versions of python installed on a system to easily switch between python versions.
Installing Pyenv
Using zsh
shell instead of bash
.
Add to ~/.zshrc
and ~/.zprofile
:
# Add pyenv executable to PATH and
# enable shims by adding the following
# to ~/.profile and ~/.zprofile:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
To allow switching in local shell adding the above to ~/.zprofie
should allow for in terminal switch.
Installing Pyenv with Debian
Debian Installation
To install new python versions using pyenv
, there are a few dependencies that may be required to avoid errors during compiling from the source:
$ sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
Poetry
Poetry is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. Poetry offers a lockfile to ensure repeatable installs, and can build your project for distribution. Ref: Poetry Docs
Poetry Installation
curl -sSL https://install.python-poetry.org | python -
If using oh-my-zsh
:
mkdir $ZSH_CUSTOM/plugins/poetry
poetry completions zsh > $ZSH_CUSTOM/plugins/poetry/_poetry
When working on a project you can use:
poetry config virtualenvs.in-project true
This will set up a virtual environment in your local project, just be sure to add to your .gitignore
to prevent sync with your svn
.