EthioDeploy
DocsPricingDomainsBlogToolsChangelog

Blog/Fix deploy errors

Python version mismatch on deploy: SyntaxError, "requires a different Python" and failed wheels

BS
Brook SolomonPublished November 29, 2026
Share on XShare on LinkedIn
.python-version

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 wheel

The 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 seeLikely causeFix
SyntaxError on code that runs locallyThe server's Python is older than yoursPin your version in .python-version
require a different python versionA pinned package needs a newer PythonPin your version, or pin the package to an older release
pip downloads a .tar.gz and fails to compileNo wheel for the server's Python, usually a newer oneUpgrade the package, or pin the older Python
The host ignores your pinIt reads another file or env var first, or doesn't know that versionCheck 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-python in pyproject.toml says 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 satisfies requires-python.
  • Pipfile has python_version under [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?

PlatformReadsDefault
Nixpacks 1.41NIXPACKS_PYTHON_VERSION, .python-version, runtime.txt, Pipfile, .tool-versions (details below)3.12
Heroku.python-version; runtime.txt is deprecatedLatest 3.15 for new apps
RenderPYTHON_VERSION env var (full version such as 3.13.5), then .python-versionDepends on when the service was created; 3.14.10 for new ones
DockerThe FROM image tagWhatever 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.14 in .python-version gives 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.4 and 3.12 both give Nixpacks' 3.12, which is 3.12.7. 3.13 gives 3.13.0.
  • .python-version beats runtime.txt when both exist.
  • NIXPACKS_PYTHON_VERSION beats .python-version, but not runtime.txt, Pipfile or .tool-versions. If any of those three is in the repo, it replaces the env var. A Pipfile without python_version replaces it with nothing, so you get the default. We confirmed both: the env var set to 3.12 with a runtime.txt saying 3.11 builds on 3.11.
  • requires-python is never read for the version, not even with a uv.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-version file with 3.13, 3.12, 3.11 or 3.10. If you also have a Heroku-era runtime.txt, delete it or make it agree, so the two can't drift.
  • Or add NIXPACKS_PYTHON_VERSION under Environment Variables with “Runtime only” off, so the build sees it, and make sure the repo has no runtime.txt, Pipfile or .tool-versions that 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:

  • Heroku: Specifying a Python version
  • Render: Setting your Python version
  • uv: Python versions
  • Nixpacks source: Python provider
  • Python Packaging: Dealing with Requires-Python
  • What's New in Python 3.12
  • psycopg2-binary on PyPI

Push a repo. Get a URL.

  • Deploy a Python app
  • Deploy a Django app
  • ModuleNotFoundError after deploy
  • Node version mismatches on deploy
Start free

Join the EthioDeploy Telegram

Release notes as they ship, plus deploy help from the team and other developers.

Join on Telegram
BS
WRITTEN BYBrook SolomonFounder, EthioDeploy

Brook Solomon founded EthioDeploy and builds its deploy pipeline, build servers and AI coding agent. The posts here come from errors seen in real deploys on the platform.

All posts by Brook →
On this page
  • What does a Python version mismatch look like?
  • Quick checklist
  • How do you pin the Python version?
  • Which file does each platform read?
  • How does Nixpacks pick the Python version?
  • What happens on EthioDeploy?
  • Questions
  • Sources
0% read

Keep reading

  • Mixed Content: blocked

    Fix deploy errorsNov 29, 2026

    Mixed content blocked after moving to HTTPS: causes and fixes

    A mixed content error means the page loaded over HTTPS but asked for something over plain http://. Browsers block scripts, stylesheets, fetch() and XMLHttpRequest calls (Chrome: "This request has been blocked; the content must be served over HTTPS") and upgrade images, audio and video to https on their own. After a deploy the cause is usually one of three things: an http:// URL in your code or in an env var such as the API base URL, a backend behind a TLS-terminating proxy that thinks it runs on http and builds http:// links, or old http:// URLs saved in the database. Change the URLs to https:// or relative paths, make the framework trust X-Forwarded-Proto, and treat the upgrade-insecure-requests CSP directive as a stopgap.

  • Health check failed

    Fix deploy errorsNov 29, 2026

    Health check failed: app not listening on its port

    A deploy fails its health check when the platform starts the new version and gets no healthy answer in time. There are four reasons: nothing listens on the port the platform probes, the process exits, the app takes longer to start than the platform waits, or it answers the check path with an error status such as 404. Render logs "No open ports detected" and fails the deploy, Railway marks the deploy failed when the healthcheck path returns no 2xx within 300 seconds, Fly warns "The app is not listening on the expected address", and Heroku kills a web process that hasn't bound to $PORT within 60 seconds (R10). Read the log to see which of the four it is: then listen on 0.0.0.0 and $PORT, move slow work out of startup, or point the health check at a route that returns 200.

  • wss://

    Fix deploy errorsNov 29, 2026

    "WebSocket connection failed" after deploy: proxies, wss and idle timeouts

    "WebSocket connection to 'wss://...' failed" after deploy means the handshake never reached your app or the app's answer never came back. Check four things in order. Use wss:// with the same host as the page, or a relative URL: browsers refuse ws:// from an https page. Make sure the proxy forwards the Upgrade and Connection headers; Nginx drops them unless you set them, while Traefik and Cloudflare pass them on their own. Serve the socket on the same port as your HTTP app, because hosts route one port. If connections open and then die after a minute or so, an idle timeout closed them: send pings every 25 to 30 seconds and reconnect on close. Platforms that sleep idle apps also close open sockets when they stop the app.

EthioDeploy

Agentic first development and deployment, started in Ethiopia, built for developers everywhere.

Telegram community
Product
PricingAI coding agentAgent mode docsDomainsCLIFree backend hostingHosting in EthiopiaChangelog
Deploy guides
Next.jsNode.jsPythonSvelteKitTanStack StartAstroNuxtReact RouterHonoStrapiPayload CMSDjangoDjango + CeleryFastAPIFlaskStreamlitExpressNestJSSocket.IOLaravelRailsGoSpring BootASP.NET CoreTelegram botDiscord botWhatsApp botn8nLovableBoltReplitv0Google AI StudioBase44Firebase StudioClaude Code & Cursor
Compare
vs Herokuvs Vercelvs Rendervs Railwayvs Fly.iovs Netlifyvs KoyebHeroku alternativesVercel alternativesNetlify alternativesRender alternativesRailway alternativesFly.io alternativesReplit alternativesPythonAnywhere alternativesDigitalOcean App Platform alternativesGlitch alternatives
Resources
DocsBlogFree toolsAboutSupportContactllms.txt
© 2026 EthioDeployPay by card in USD or bank transfer in ETBTermsPrivacy