Skip to navigation
Use uv python for install
20.11.26
``` curl -LsSf https://astral.sh/uv/install.sh | sh uv python install 3.11 uv python list cd /home/veto/webs/code/bp poetry env use "$(uv python find 3.11)" poetry install ``` # Python for bp with uv The project pins `requires-python = ">=3.11,<3.13"` (see `pyproject.toml`), and `django==3.2.25` does **not** run on Python 3.13. Debian 13 only ships 3.13, so the interpreter has to come from somewhere else. `uv` installs a prebuilt CPython (3.11/3.12) in seconds — no compiler, no system packages, no `ldconfig`, nothing shadowed in `/usr/bin`. --- ## 1. Install uv ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` The binary lands in `~/.local/bin/uv`. Make sure it is on `PATH`: ```bash export PATH="$HOME/.local/bin:$PATH" uv --version ``` Add that `export` line to `~/.bashrc` (or `~/.profile`) to keep it. Other install options: ```bash # Debian package (older versions) sudo apt-get install -y uv # pipx pipx install uv ``` --- ## 2. Install Python 3.11 ```bash uv python install 3.11 uv python list ``` `uv python list` shows every version uv knows about, with the installed ones marked. The interpreter lives under `~/.local/share/uv/python/`. Why 3.11: it matches the production host and satisfies the project range. Use `3.12` instead if you prefer the newest supported version. --- ## 3. Point Poetry at it ```bash cd /home/veto/webs/code/bp poetry env use "$(uv python find 3.11)" poetry install ``` Verify what Poetry picked: ```bash poetry env info poetry run python -V ``` The venv now records the absolute path to uv's interpreter, so later `poetry install` / `poetry run` calls keep using it. --- ## 4. Pin the version in the repo (optional) ```bash uv python pin 3.11 ``` This writes `.python-version`. Commit it if you want every checkout on the same interpreter; `uv run` and other uv-aware tools will read it automatically. --- ## Daily use | Task | Command | |------|---------| | Run a management command | `poetry run python pgtest/manage.py
` | | Open a Django shell | `poetry run python pgtest/manage.py shell` | | Add a dependency | `poetry add
` | | Re-sync the venv | `poetry install` | | Show the interpreter | `poetry env info` | | List uv's Pythons | `uv python list` | | Remove a uv Python | `uv python uninstall 3.11` | If a tool insists on a `python3.11` on `PATH`, symlink it: ```bash ln -s "$(uv python find 3.11)" ~/.local/bin/python3.11 ``` --- ## Ownership note If Poetry is run as **root** while the repo belongs to `1000:33`, the virtualenv is created root-owned. Either run Poetry as uid 1000, or fix it afterwards: ```bash chown -R 1000:33 /home/veto/webs/code/bp ``` Poetry's env cache lives in `~/.cache/pypoetry/virtualenvs/`. --- ## uv vs. building from source | | uv | `./configure && make altinstall` | |---|---|---| | Time | seconds | 10–20 min (`--enable-optimizations`) | | Build deps | none | `build-essential` + ~10 `-dev` packages | | System impact | none (per-user dir) | `/usr/local/bin/python3.11`, `/usr/local/lib` | | `ldconfig` | not needed | needed with `--enable-shared` | | Speed of Python | PGO + LTO prebuilt | PGO + LTO, equivalent | | Remove | `uv python uninstall` | manual `rm` of `/usr/local` files | | Best for | dev venvs (this project) | system-wide interpreter for other services | --- ## Troubleshooting **`Poetry was unable to find a compatible version`** No 3.11/3.12 is installed. Run `uv python install 3.11`, then `poetry env use "$(uv python find 3.11)"`. **`command not found: uv`** `~/.local/bin` is not on `PATH` — see step 1. **Poetry still uses 3.13** `poetry env use` only affects the current project. Check with `poetry env info`; if the venv already exists, recreate it with `poetry env remove python` first. **`pymssql` / `psycopg2` build errors** Both publish cp311/cp312 wheels; a build error usually means Poetry fell back to the system 3.13. Confirm the interpreter with `poetry run python -V`. v.md
Reply
Anonymous
Information Epoch 1795523555
There is no perfect productivity system.
Home
Notebook
Contact us