-
Notifications
You must be signed in to change notification settings - Fork 0
Python Project ‐ Poetry
Steve Gibbard edited this page Feb 27, 2025
·
1 revision
The following assume you have pyenv and poetry installed
List available versions locally
% pyenv versions
system
3.10.13
* 3.11.8 (set by /Users/username/.pyenv/version)List all available Python versions of 3.12
% pyenv install --list | grep 3.12
3.12.0
3.12-dev
3.12.1
3.12.2Install a Python version
% pyenv install 3.12.2
python-build: use openssl@3 from homebrew
python-build: use readline from homebrew
Downloading Python-3.12.2.tar.xz...Set the local version for the project
% cd my_project
% pyenv local 3.12.2
% pyenv versions
system
3.10.13
3.11.8
* 3.12.2 (set by /Users/username/Development/ai_agent/.python-version)Check Python version
% python --version
Python 3.12.2Init a Poetry Project
% poetry initAlternatively create with defaults
% poetry new .Use the pyenv Python version
% poetry env use $(pyenv which python)
Creating virtualenv ai-agent-wJEa74kU-py3.12 in /Users/username/Library/Caches/pypoetry/virtualenvs
Using virtualenv: /Users/username/Library/Caches/pypoetry/virtualenvs/ai-agent-wJEa74kU-py3.12Check the virtual env is setup correctly
% poetry env infoActivate virtual env
% poetry shellExecute a python script using poetry
% poetry run python main.pyAdd application dependencies
% poetry add requestsAdd dev dependencies
% poetry add --dev pytestCheck
% poetry check
All set!