iTranslated by AI
Python Development Environment
(Updated 2025/07/07) In 2025, using uv is the best choice. It integrates various functions that were previously handled by separate tools and is extremely fast. Start by introducing uv.
I'm stuck with pip and pyenv. I researched it because I didn't understand which commands use which features or how files and folders relate to each command.
pip
pip: Python Environment Setup Guide - python.jp
pip is a utility for tasks such as installing Python packages published on The Python Package Index, and it has been included by default since Python 3.4.
I think of it as something like npm for Node.js.
requirements.txt is a file where the list of dependency libraries installed via pip is managed. I think it's close to package-lock.json in Node.js.
pyenv
pyenv lets you easily switch between multiple versions of Python. It's simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.
This project was forked from rbenv and ruby-build, and modified for Python.
I think of it as something like nodenv or nvm for Node.js.
The .python-version file is the one for pyenv. It instructs pyenv on the default Python version for that folder and its subdirectories.
virtualenv
Virtual Environments: Python Environment Setup Guide - python.jp
When performing development or experimentation using Python, it is common to create and switch between dedicated execution environments depending on the purpose. These temporarily created execution environments are called "virtual environments".
Basically, wanting to separate Python versions and such for each project.
Here, we introduce how to create a virtual environment using venv, which is a standard library in Python 3.
Despite saying that, the next step is pip install virtualenv.
virtualenv == venv ???
Difference between venv and virtualenv - 🍊miyamonz🍊
Some features of virtualenv were extracted as venv and incorporated into the standard library. virtualenv continues to have other features, and it seems development is still ongoing as of 2020.
I see.
The .venv folder is commonly used in virtualenv to store information about the virtual environment and dependency libraries. The name .venv seems to be a de facto convention rather than a specification.
It can also be installed via Homebrew: brew install virtualenv
pyenv-virtualenv
pyenv/pyenv-virtualenv: a pyenv plugin to manage virtualenv (a.k.a. python-virtualenv)
pyenv-virtualenv is a pyenv plugin that provides features to manage virtualenvs and conda environments for Python on UNIX-like systems.
This is a pyenv plugin that provides functionality to manage virtualenv and conda environments for Python on UNIX-like systems.
It can also be installed via Homebrew: brew install pyenv-virtualenv.
You can create different environments even if the Python version is the same.
This is because if the projects are different, you want to manage them as separate environments (virtual environments) even if they happen to use the same Python version.
poetry
One of Python's package managers, it is a peer to pip but arrived later.
I think of its positioning as close to yarn or pnpm for Node.js.
-
pyproject.tomlis a project configuration file created bypoetry neworpoetry init. I think it's close topackage.jsonin Node.js. - By the way, you can output the usual
requirements.txtformat by running something likepoetry export -o requirements.txt --without-hashes. -
poetry.lockis a file created when you runpoetry install, etc., containing version information for each dependency library. It's close topackage-lock.jsonin Node.js. It follows a standard Python format. -
poetry.tomlis a file that holds the configuration for poetry itself for that specific project, updated by commands likepoetry config -local. There are some articles online wherepyproject.tomlandpoetry.tomlare confused.
Reference
Various development environment tools like Linters and Formatters
isort # Formatter: Sort imports
black # Formatter: All '' were changed to ""...
flake8 # Linter
mypy # Linter: Check type hints
pysen # Execution organizer for the above four. You can run all of them with 'pysen run lint'.
Reference
Discussion