python-env
Python Environment Management
Virtual environments, dependency management, and Python version control.
venv (Built-in)
# Create virtual environment
python -m venv .venv
python3 -m venv .venv
# Activate
source .venv/bin/activate # Linux/macOS
.venv\Scripts\activate # Windows
# Deactivate
deactivate
# Install packages
pip install requests flask
pip install -r requirements.txt
# Freeze dependencies
pip freeze > requirements.txt
# Upgrade pip
pip install --upgrade pip
requirements.txt
# Pinned versions (production)
flask==3.0.0
requests==2.31.0
sqlalchemy==2.0.23
# Ranges (library development)
flask>=3.0,<4.0
requests~=2.31 # Compatible release (>=2.31, <3.0)
# With extras
fastapi[all]==0.104.0
# From git
git+https://github.com/user/repo.git@main#egg=package
# Separate dev dependencies
pip install -r requirements.txt
pip install -r requirements-dev.txt
Poetry
# Install Poetry
curl -sSL https://install.python-poetry.org | python3 -
# Create new project
poetry new my-project
poetry init # In existing project
# Add dependencies
poetry add requests flask
poetry add pytest --group dev
poetry add "sqlalchemy>=2.0,<3.0"
# Remove dependency
poetry remove requests
# Install all dependencies
poetry install
poetry install --without dev
# Update dependencies
poetry update
poetry update requests # Single package
# Show dependencies
poetry show
poetry show --tree
# Run command in virtualenv
poetry run python main.py
poetry run pytest
# Activate shell
poetry shell
# Build & publish
poetry build
poetry publish
# Export to requirements.txt
poetry export -f requirements.txt --output requirements.txt
poetry export -f requirements.txt --without-hashes
pyproject.toml (Poetry)
[tool.poetry]
name = "my-project"
version = "1.0.0"
description = "My project"
authors = ["Name <email@example.com>"]
python = "^3.11"
[tool.poetry.dependencies]
python = "^3.11"
flask = "^3.0"
sqlalchemy = "^2.0"
[tool.poetry.group.dev.dependencies]
pytest = "^8.0"
ruff = "^0.1"
mypy = "^1.7"
[tool.poetry.scripts]
serve = "my_project.main:app"
uv (Fast Python Package Manager)
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create virtual environment
uv venv
# Install packages (10-100x faster than pip)
uv pip install requests flask
uv pip install -r requirements.txt
# Sync from lock file
uv pip sync requirements.txt
# Compile requirements (resolve + lock)
uv pip compile requirements.in -o requirements.txt
# Create project
uv init my-project
# Add dependency
uv add requests
uv add pytest --dev
# Run
uv run python main.py
pyenv (Python Version Management)
# Install pyenv
curl https://pyenv.run | bash
# List available versions
pyenv install --list | grep "3\."
# Install Python version
pyenv install 3.12.1
pyenv install 3.11.7
# Set global default
pyenv global 3.12.1
# Set local version (per directory)
pyenv local 3.11.7 # Creates .python-version
# List installed
pyenv versions
# Uninstall
pyenv uninstall 3.10.0
Pipenv
# Install
pip install pipenv
# Create environment + install
pipenv install
pipenv install requests
pipenv install pytest --dev
# Run in environment
pipenv run python main.py
pipenv shell
# Lock dependencies
pipenv lock
# Install from lock file
pipenv install --deploy
# Show dependency graph
pipenv graph
conda
# Create environment
conda create -n myenv python=3.12
conda create -n myenv python=3.12 numpy pandas
# Activate/deactivate
conda activate myenv
conda deactivate
# Install packages
conda install numpy pandas
conda install -c conda-forge package-name
# List environments
conda env list
# Export environment
conda env export > environment.yml
# Create from file
conda env create -f environment.yml
# Remove environment
conda env remove -n myenv
Common Issues
# "pip not found" after creating venv
python -m pip install --upgrade pip
# Permission errors
pip install --user package-name
# Conflicting versions
pip install --force-reinstall package==1.0
# Clear pip cache
pip cache purge
# Check what's outdated
pip list --outdated
# Verify installation
python -c "import package; print(package.__version__)"
Reference
For comparison and migration guides: references/tools.md
More from 1mangesh1/dev-skills-collection
curl-http
HTTP request construction and API testing with curl and HTTPie. Use when user asks to "test API", "make HTTP request", "curl POST", "send request", "test endpoint", "debug API", "upload file", "check response time", "set auth header", "basic auth with curl", "send JSON", "test webhook", "check status code", "follow redirects", "rate limit testing", "measure API latency", "stress test endpoint", "mock API response", or any HTTP calls from the command line.
28database-indexing
Database indexing internals, index type selection, query plan analysis, and write-overhead tradeoffs across PostgreSQL, MySQL, and MongoDB. Use when user asks to "optimize queries", "create indexes", "fix slow queries", "read EXPLAIN output", "reduce query time", "index strategy", "database performance", "composite index", "covering index", "partial index", "index bloat", "unused indexes", or needs help diagnosing and resolving database performance problems.
13testing-strategies
Testing strategies, patterns, and methodologies across the full testing spectrum. Use when asked about unit tests, integration tests, e2e tests, test pyramid, mocking, test doubles, TDD, property-based testing, snapshot testing, test coverage, mutation testing, contract testing, performance testing, test data management, CI/CD testing, flaky tests, test anti-patterns, test organization, test isolation, test fixtures, test parameterization, or any testing strategy, approach, or methodology.
10secret-scanner
This skill should be used when the user asks to "scan for secrets", "find API keys", "detect credentials", "check for hardcoded passwords", "find leaked tokens", "scan for sensitive keys", "check git history for secrets", "audit repository for credentials", or mentions secret detection, credential scanning, API key exposure, token leakage, password detection, or security key auditing.
10terraform
Terraform infrastructure as code for provisioning, modules, state management, and workspaces. Use when user asks to "create infrastructure", "write Terraform", "manage state", "create module", "import resource", "plan changes", or any IaC tasks.
10kubernetes
Kubernetes and kubectl mastery for deployments, services, pods, debugging, and cluster management. Use when user asks to "deploy to k8s", "create deployment", "debug pod", "kubectl commands", "scale service", "check pod logs", "create ingress", or any Kubernetes tasks.
10