Question Details

No question body available.

Tags

python django postgresql windows-subsystem-for-linux postgis

Answers (1)

January 4, 2026 Score: 0 Rep: 21 Quality: Low Completeness: 80%

It is neither Django nor Python issue. Especially venv has nothing to do with it. Using apt in venv or not installs packages globally in your OS. This issue is solely between your Postgres and Postigs system-wide installations.

I did reproduce your setup using your Postgres and Postgis installation commands (in reverse order and with required sudo apt update after curl command) in Ubuntu 24.04.03. In my setup Postgis extension can be created with CREATE EXTENSION postgis;.

What might be wrong in your setup

You can check whether packages are installed or not, using apt list --installed. In my working setup I get:

$ apt list --installed postgis postgresql-18
postgis/noble-pgdg,now 3.6.1+dfsg-1.pgdg24.04+1 amd64 [installed]
postgresql-18/noble-pgdg,now 18.1-1.pgdg24.04+2 amd64 [installed]

As all apt installations are system-wide, if you are installing more than one Postgres servers in one OS you might end up running and connecting to wrong one.
For example if you install packages in following order

$ sudo apt install postgresql-17
$ sudo apt install postgresql-18
$ sudo apt install postgis

and then not configure anything, you will probably get a conflict. Reasoning from my tests it looks like the first Postgres you install is ran by default. But apt doesn't know whichever you are running, so Postgis will be installed for Postgresql 18, the latest one. Default systemd postgres service will still serve Postgres 17.
You can check if you are on correct Postgres version by running

SELECT version();

while connected to db, or

$ pglsclusters

in shell.
If you serve wrong one, which I find highly probable, to create a new one you can use

$ pgcreatecluster 18 pg18

Note that this command will list new (configurable) port that you will have to use in your app configuration.


Note: I am aware this answer contains assumptions that might be not correct. After OP gives more insights on their setup I will edit.