Setup Python and Poetry

date
May 10, 2021
slug
setup-python-and-poetry
author
status
Public
tags
Notes
summary
Quick notes showing how to install Python and Poetry
type
Post
thumbnail
poetry.png
updatedAt
May 10, 2023 09:06 PM

Install pyenv to manage Python installation.

Please note, do not try to use System Python as the default system.
Install pyenv :
brew install pyenv
 
Install Python:
pyenv install 3.9.10
 
Add the following to your ~/.bash_profile or ~/.zshrc:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/shims:$PATH"
 
In order to access a remote repository make sure to update this file $HOME/.pip/pip.conf
vi $HOME/.pip/pip.conf
add your config:
[global]
index-url = "<REMOTE REPOSITORY>"
 

Configuring pipx:

Install pipx using brew:
brew install pipx
pipx ensurepath 
 

Installing Poetry:

Run the following to determine number of python versions.
pyenv versions
 
Single Python Installation:
pipx install poetry
poetry --version
 
Multiple Python Installations:
pyenv global <PYTHON VERSION>
pipx install poetry --python $(which python)
poetry env use $(which python)
poetry --version
 

Upgrade Poetry:

pipx upgrade poetry