Last active
September 5, 2025 16:31
-
-
Save ashishjullia/4fe550094c6a19889cab60200ba35abb to your computer and use it in GitHub Desktop.
uv python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uv init (defaults to --app) | |
| gives: | |
| ├── .git | |
| ├── .gitignore | |
| ├── .python-version | |
| ├── main.py | |
| ├── pyproject.toml | |
| └── README.md | |
| uv add <package> | |
| And then you can check which package installed/comes with which packages/deps: | |
| uv tree | |
| Resolved 6 packages in 3ms | |
| test-aws-nova-act v0.1.0 | |
| └── requests v2.32.5 | |
| ├── certifi v2025.8.3 | |
| ├── charset-normalizer v3.4.3 | |
| ├── idna v3.10 | |
| └── urllib3 v2.5.0 | |
| If you change the version in .python-version and it had the version from initial "uv init" run sourced from system then it will throw error with the context of current dir: | |
| uv tree | |
| Using CPython 3.12.11 | |
| error: The Python request from `.python-version` resolved to Python 3.12.11, which is incompatible with the project's Python requirement: `>=3.13` (from `project.requires-python`) | |
| Use `uv python pin` to update the `.python-version` file to a compatible version | |
| If if it a fresh project with basic uv related files but not with .venv then you can simple run: | |
| uv sync | |
| what if there is an existing project that uses plain requirements.txt and might also have existing venv config, how to migrate from it? | |
| uv init | |
| But how to get those packages from requirments.txt? | |
| uv add -r requirements.txt | |
| > this will auto update pyproject.toml and uv.lock | |
| uv python install <python-version> | |
| uv pip uninstall <package> | |
| uv pip install <package> | |
| uv pip freeze > requirements.txt | |
| uv pip install --refresh -r requirements.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment