Usage
Description
Initialize a new Python project following thepyproject.toml specification.
If a pyproject.toml already exists at the target, uv will exit with an error.
If a pyproject.toml is found in any of the parent directories of the target path, the project will be added as a workspace member of the parent.
Some project state is not created until needed:
- The project virtual environment (
.venv) is created lazily during the first sync - The lockfile (
uv.lock) is created during the first sync
Arguments
The path to use for the project/script.Defaults to the current working directory when initializing an app or library. Required when initializing a script. Accepts relative and absolute paths.If a
pyproject.toml is found in any of the parent directories of the target path, the project will be added as a workspace member of the parent, unless --no-workspace is provided.Options
Project Configuration
The name of the project.Defaults to the name of the directory. Cannot be used with
--script.--package
Set up the project to be built as a Python package.Defines a
[build-system] for the project. This is the default behavior when using --lib or --build-backend.When using --app, this will include a [project.scripts] entrypoint and use a src/ project structure.--no-package
Do not set up the project to be built as a Python package.Does not include a
[build-system] for the project. This is the default behavior when using --app.--app
Create a project for an application.This is the default behavior if
--lib is not requested. This project kind is for web servers, scripts, and command-line interfaces.By default, an application is not intended to be built and distributed as a Python package. The --package option can be used to create an application that is distributable.--lib
Create a project for a library.A library is a project that is intended to be built and distributed as a Python package.
--script
Create a script.A script is a standalone file with embedded metadata enumerating its dependencies, along with any Python version requirements, as defined in the PEP 723 specification.PEP 723 scripts can be executed directly with
uv run.By default, adds a requirement on the system Python version; use --python to specify an alternative Python version requirement.--bare
Only create a
pyproject.toml.Disables creating extra files like README.md, the src/ tree, .python-version files, etc.When combined with --script, the script will only contain the inline metadata header.Set the project description.
--no-description
Disable the description for the project.
Build Configuration
Initialize a build-backend of choice for the project.Implicitly sets
--package. Options include:hatchling- Use Hatchling as the build backendflit- Use Flit as the build backendpdm- Use PDM as the build backendsetuptools- Use setuptools as the build backendmaturin- Use Maturin as the build backendscikit- Use scikit-build-core as the build backend
UV_INIT_BUILD_BACKENDVersion Control
Initialize a version control system for the project.By default, uv will initialize a Git repository (
git). Use --vcs none to explicitly avoid initializing a version control system.--no-readme
Do not create a
README.md file.Fill in the
authors field in the pyproject.toml.By default, uv will attempt to infer the author information from some sources (e.g., Git) (auto). Use --author-from git to only infer from Git configuration. Use --author-from none to avoid inferring the author information.Python Configuration
The Python interpreter to use to determine the minimum supported Python version.See
uv help python to view supported request formats.Environment variable: UV_PYTHON--no-pin-python
Do not create a
.python-version file for the project.By default, uv will create a .python-version file containing the minor version of the discovered Python interpreter, which will cause subsequent uv commands to use that version.Workspace Options
--no-workspace
Avoid discovering a workspace and create a standalone project.By default, uv searches for workspaces in the current directory or any parent directory.
Examples
Create a new application
my-app directory with a basic structure.
Create a new library
Create a PEP 723 script
Create a project with a specific build backend
Create a bare project
pyproject.toml file without additional scaffolding.