Python version mismatch on deploy: SyntaxError, "requires a different Python" and failed wheels
THE SHORT ANSWER
If your app works locally and the deploy fails with a SyntaxError on valid code, "Ignored the following versions that require a different python version", or a wheel that won't build, the server is running a different Python than you are. Check with python --version locally and in the build log, then pin the same minor version in a .python-version file containing just 3.12 (or whatever you use). Heroku, Render, uv and pyenv all read that file; runtime.txt is deprecated on Heroku. Nixpacks, which EthioDeploy uses, reads NIXPACKS_PYTHON_VERSION, .python-version and runtime.txt, knows only 3.7 to 3.13, and silently falls back to 3.12 for anything else. requires-python in pyproject.toml doesn't choose the interpreter on any of them except uv. With a Dockerfile, the FROM line decides.
What does a Python version mismatch look like?
There's no single error message. The same mismatch shows up in three different ways depending on what breaks first. These are real outputs from Python 3.11 running code and requirements written for 3.12:
# 1. Syntax added in a newer Python (here PEP 695, new in 3.12)
File "/app/models.py", line 1
type UserId = int
^^^^^^
SyntaxError: invalid syntax
# Same quotes inside an f-string (PEP 701, also 3.12)
print(f"{", ".join(names)}")
^
SyntaxError: f-string: expecting '}'
# 2. A dependency that needs a newer Python
ERROR: Ignored the following versions that require a different python version: 6.0 Requires-Python >=3.12; 6.0.1 Requires-Python >=3.12; ...
ERROR: Could not find a version that satisfies the requirement django>=6 (from versions: ..., 5.2.19)
ERROR: No matching distribution found for django>=6
# Your own project declares requires-python and is installed with pip install .
ERROR: Package 'myapp' requires a different Python: 3.11.18 not in '>=3.12'The third kind goes the other way: the server's Python is newer than a pinned package supports. pip finds no prebuilt wheel for that Python, downloads the source and tries to compile it. Here is psycopg2-binary==2.9.9, which has no wheels for 3.13, installing on Python 3.13:
Collecting psycopg2-binary==2.9.9
Downloading psycopg2-binary-2.9.9.tar.gz (384 kB)
...
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source.
...
ERROR: Failed to build 'psycopg2-binary' when getting requirements to build wheelThe clue is the .tar.gz. When pip downloads a source archive for a package that usually ships wheels, and then complains about a missing compiler, header or tool, the package version is older than the Python running it. Upgrade the package (2.9.10 added 3.13 wheels) or build on the Python you developed on.
One more variant: the module no longer exists in the newer Python, like distutils in 3.12. That one surfaces as ModuleNotFoundError, covered in ModuleNotFoundError after deploy.
Quick checklist
| What you see | Likely cause | Fix |
|---|---|---|
SyntaxError on code that runs locally | The server's Python is older than yours | Pin your version in .python-version |
require a different python version | A pinned package needs a newer Python | Pin your version, or pin the package to an older release |
pip downloads a .tar.gz and fails to compile | No wheel for the server's Python, usually a newer one | Upgrade the package, or pin the older Python |
| The host ignores your pin | It reads another file or env var first, or doesn't know that version | Check the host's order (table below) and print the version in the build |
How do you pin the Python version?
Find the version you actually run, then write its major and minor version to a .python-version file in the repo root:
python --version # Python 3.12.7 echo "3.12" > .python-version git add .python-version
Leave out the patch number. Heroku's docs recommend the major version only “so that your app automatically receives Python security updates each time it builds”. The same file is what pyenv and uv use locally (uv python pin 3.12 writes it for you), so your machine and the server read one source.
The other places a version can live, and what reads them:
runtime.txt(python-3.12.7) is the old Heroku format. Heroku now calls it deprecated and recommends.python-version. Nixpacks still reads it.requires-pythoninpyproject.tomlsays which Pythons your project supports. pip checks it when it installs your project and refuses a mismatch, as shown above, but it doesn't pick the interpreter. uv is the exception: with no.python-version, it uses the first installed Python that satisfiesrequires-python.Pipfilehaspython_versionunder[requires], read by pipenv and nixpacks.- In a Dockerfile, the base image is the version:
FROM python:3.12-slim. No file in the repo changes it.
Which file does each platform read?
| Platform | Reads | Default |
|---|---|---|
| Nixpacks 1.41 | NIXPACKS_PYTHON_VERSION, .python-version, runtime.txt, Pipfile, .tool-versions (details below) | 3.12 |
| Heroku | .python-version; runtime.txt is deprecated | Latest 3.15 for new apps |
| Render | PYTHON_VERSION env var (full version such as 3.13.5), then .python-version | Depends on when the service was created; 3.14.10 for new ones |
| Docker | The FROM image tag | Whatever python:3 or latest points to that day |
Note the defaults. A repo with no pin builds on 3.12 with Nixpacks, 3.14 on a new Render service and 3.15 on a new Heroku app. Code that works on one can fail on another for exactly the reasons above, which is why a pin beats relying on any default.
Whatever the host, print the version once in the build command (python --version && in front of it), read the log, and compare it with your machine.
How does Nixpacks pick the Python version?
Nixpacks, which EthioDeploy uses, maps your pin to a Nix package. We read its Python provider source and checked each case with nixpacks plan on 1.41.0:
- Only 2.7 and 3.7 through 3.13 are recognized.
3.14in.python-versiongives no error and builds on the default, 3.12. If you develop on 3.14, that is the “works locally” gap: pin 3.13 or use a Dockerfile. - The patch is ignored.
3.12.4and3.12both give Nixpacks' 3.12, which is 3.12.7. 3.13 gives 3.13.0. .python-versionbeatsruntime.txtwhen both exist.NIXPACKS_PYTHON_VERSIONbeats.python-version, but notruntime.txt,Pipfileor.tool-versions. If any of those three is in the repo, it replaces the env var. APipfilewithoutpython_versionreplaces it with nothing, so you get the default. We confirmed both: the env var set to 3.12 with aruntime.txtsaying 3.11 builds on 3.11.requires-pythonis never read for the version, not even with auv.lock.
What happens on EthioDeploy?
Python apps without a Dockerfile build with Nixpacks, and EthioDeploy passes no Python version of its own, so everything in the previous section applies as written. With no pin you get Python 3.12.7.
To choose the version:
- Commit a
.python-versionfile with3.13,3.12,3.11or3.10. If you also have a Heroku-eraruntime.txt, delete it or make it agree, so the two can't drift. - Or add
NIXPACKS_PYTHON_VERSIONunder Environment Variables with “Runtime only” off, so the build sees it, and make sure the repo has noruntime.txt,Pipfileor.tool-versionsthat would replace it. - For Python 3.14 or later, deploy with a Dockerfile starting
FROM python:3.14-slim. A Dockerfile in the repo replaces Nixpacks entirely.
Then redeploy and check the build log. Start commands and the rest of the setup are in the Python deploy guide. The Node version of this problem, with engines.node and .nvmrc, is in The engine "node" is incompatible.
Questions
The server runs an older Python than you do, and your code uses syntax that Python doesn't know yet, such as match (3.10), the type statement or nested quotes in f-strings (3.12). Pin your local version in .python-version and redeploy.
pip found releases of the package that would satisfy your requirement, but their Requires-Python excludes the Python running the install, so it skipped them and then reports no matching distribution. Build on a newer Python, or pin the package to a release that supports yours.
.python-version. Heroku has deprecated runtime.txt, and .python-version is also what pyenv, uv, Render and Nixpacks read. Put only the major and minor version in it, like 3.12.
Not on Heroku, Render or Nixpacks. pip uses it to refuse installing your project on an unsupported Python, but the host picks the interpreter from .python-version or its own setting. uv does use requires-python to choose an interpreter when there is no .python-version.
Python 3.12.7 unless you pin one. A .python-version file with 3.10 to 3.13, or the NIXPACKS_PYTHON_VERSION env var, selects another. For 3.14 or newer, use a Dockerfile.
Sources
Checked on November 29, 2026:
Push a repo. Get a URL.
- Deploy a Python app
- Deploy a Django app
- ModuleNotFoundError after deploy
- Node version mismatches on deploy
Join the EthioDeploy Telegram
Release notes as they ship, plus deploy help from the team and other developers.