Set up Poetry for Python dependency and package management
✓Works with OpenClaudeYou are a Python developer. The user wants to set up Poetry for managing Python dependencies and packages in a new or existing project.
What to check first
- Run
python --versionto confirm Python 3.7+ is installed - Check if Poetry is already installed with
poetry --version - Verify you're in your project root directory with
lsorpwd
Steps
- Install Poetry globally using the official installer:
curl -sSL https://install.python-poetry.org | python3(on Windows, use PowerShell or download from python-poetry.org) - Add Poetry to your PATH by running
export PATH="$HOME/.local/bin:$PATH"(Linux/macOS) or restart terminal after installation (Windows) - Verify installation with
poetry --version - Initialize a new Poetry project with
poetry initin an empty directory, orpoetry installin a directory with an existingpyproject.toml - Answer the interactive prompts for project name, version, description, author, and dependencies
- Add your first dependency with
poetry add requests(replace with your package name) - Install all dependencies from
pyproject.tomlwithpoetry install - Activate the virtual environment with
poetry shellor prefix commands withpoetry run
Code
# pyproject.toml example (auto-generated after poetry init)
[tool.poetry]
name = "my-project"
version = "0.1.0"
description = "A sample Poetry project"
authors = ["Your Name <you@example.com>"]
readme = "README.md"
packages = [{include = "my_project"}]
[tool.poetry.dependencies]
python = "^3.8"
requests = "^2.31.0"
click = "^8.1.0"
[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
black = "^23.7.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
# Example Python script using Poetry
import requests
def fetch_data(url):
response = requests.get(url)
response.raise_for_status()
return response.json()
if __name__ == "__main__":
data = fetch_data("https://api.example.com/data")
print(data)
Pitfalls
- Poetry creates a
.venvvirtual environment by default — don't delete it or commit it to git (add.venvto.gitignore) - Running
poetry installwithout apyproject.tomlwill fail — always runpoetry initfirst or copy an existingpyproject.toml - Windows users must use PowerShell (not CMD) for the curl installer, or download the executable from the official website
- Specifying
python = "^3.8"locks your project to Python 3.8
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Python Skills
Other Claude Code skills in the same category — free to download.
Django Setup
Scaffold Django project with models, views, and URLs
Flask Setup
Scaffold Flask application with blueprints and extensions
FastAPI Setup
Scaffold FastAPI with async endpoints and auto-docs
Pytest Setup
Configure pytest with fixtures, plugins, and coverage
Python Venv
Set up Python virtual environments and dependency management
Python Typing
Add comprehensive type hints and mypy configuration to Python code
Django REST Framework
Set up Django REST Framework with serializers and viewsets
Python Logging
Configure structured logging for Python applications
Want a Python skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.