I'm resurrecting my local environment for a Django project that I haven't run locally in 2 years, working through issues around things that have gone stale. But I have one a little different: it looks like Django is finding/using an older version of PostgreSQL than the version I see in the venv itself. What's a good approach for tracking down old versions so I can remove them?
When I run python mysite/manage.py runserver, I get
django.db.utils.NotSupportedError: PostgreSQL 13 or later is required (found 10.13).
BUT when I check package versions in the venv I'm running, most packages are current, and PostgreSQL is 3.12.5 (not 13 or later like we'll ultimately need, but also not 10.13).
(from pip list) Django 5.1
(from pip list) psycopg2 2.9.9
(from pip list) psycopg2-binary 2.9.9
(from pip list) psycopg2-pool 1.2
psql -V gives: psql (PostgreSQL) 12.3
python -v gives: Python 3.12.5
Unsurprisingly, if I try a naive uninstall from the venv (pip uninstall postgresql-10.13), it says it's not installed.
What's a good approach for tracing where that 10.13 could be coming from?
Looking in the stack trace this NotSupportedError is raised while connecting to the database, from .venv/lib/python3.12/site-packages/django/db/backends/base/base.py", line 200, in check_database_version_supported
From the venv, my $PATH variable has:
/Users/dkaplan/.vscode/extensions/ms-python.python-2024.12.3-darwin-x64/python_files/deactivate/bash:/Users/dkaplan/family-django/.venv/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/dkaplan/.m2:/Applications/Postgres.app/Contents/Versions/latest/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/dkaplan/.vscode/extensions/ms-python.python-2024.12.3-darwin-x64/python_files/deactivate/bash:/Users/dkaplan/family-django/.venv/bin:/Library/Frameworks/Python.framework/Versions/3.12/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin
My default databases settings is:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": DB_DATABASE,
"USER": DB_USER,
"PASSWORD": DB_PASSWORD,
"HOST": DB_HOST,
"PORT": "5432",
"OPTIONS": DB_OPTIONS,
}
}
Postgres 3.12.5that is your Python version. 2)psql -V gives: psql (PostgreSQL) 12.3is telling you are using version 12.3 of the command line clientpsql. Not that you necessarily have a Postgres 12.3 server running, as it is possible to installpsqlas part of a client package. 3) You need to add to your question, as text update, what OS and version you are using and how you installed Postgres. 4) Is the Django project connecting to local or remote database?DB_HOST. I was asking to make that value explicit instead of depending on an assumption.found 10.13andpsql -V gives: psql (PostgreSQL) 12.3tends to indicate you have more then one instance of Postgres installed.