I am trying to add PostGIS extension to a postgresql database on my WSL2 (with Ubuntu 20.04) for a django project.
I have already installed postgresql, postgis and all dependencies with the following:
sudo apt -y install postgresql-12 postgresql-client-12
sudo apt install postgis postgresql-12-postgis-3
sudo apt-get install postgresql-12-postgis-3-scripts
And everything worked fine.
In postgresql, I have already created my db and connected to it:
sudo -u postgres psql -p 5432 -h 127.0.0.1
postgres=# CREATE DATABASE dbname;
postgres=# \c dbname;
But then, when I try to add the postGIS extension with:
postgres=# CREATE EXTENSION postgis;
I get the following error:
ERROR: extension "postgis" has no installation script nor update path for version "3.1.0"
And despite searching for similar questions on stackoverflow, I couldn't find any satisfactory solution for my case. Any idea what it could be wrong and how I can solve it? thank you!
EDIT:
Following command
ls $(pg_config --sharedir)/extension/postgis*
I get the following list of files:
/usr/share/postgresql/12/extension/postgis--2.0.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.0.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.0.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.0.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.0.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.0.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.0.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.0.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.1.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.1.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.1.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.1.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.1.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.1.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.1.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.1.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.1.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.1.9--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.2.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.2.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.2.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.2.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.2.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.2.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.2.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.2.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.2.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.3.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.3.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.3.10--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.3.11--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.3.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.3.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.3.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.3.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.3.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.3.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.3.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.3.9--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.4.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.4.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.4.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.4.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.4.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.4.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.4.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.4.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.4.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.4.9--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.5.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.5.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.5.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.5.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.5.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--2.5.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--3.0.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--3.0.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--3.0.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--3.0.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--3.1.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--3.1.0--3.1.0next.sql
/usr/share/postgresql/12/extension/postgis--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--3.1.0dev--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--3.1.0next--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--ANY--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--unpackaged--3.1.0.sql
/usr/share/postgresql/12/extension/postgis--unpackaged.sql
/usr/share/postgresql/12/extension/postgis.control
/usr/share/postgresql/12/extension/postgis_raster--2.0.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.0.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.0.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.0.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.0.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.0.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.0.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.0.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.1.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.1.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.1.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.1.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.1.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.1.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.1.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.1.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.1.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.1.9--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.2.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.2.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.2.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.2.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.2.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.2.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.2.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.2.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.2.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.3.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.3.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.3.10--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.3.11--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.3.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.3.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.3.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.3.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.3.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.3.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.3.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.3.9--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.4.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.4.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.4.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.4.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.4.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.4.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.4.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.4.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.4.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.4.9--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.5.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.5.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.5.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.5.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.5.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--2.5.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--3.0.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--3.0.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--3.0.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--3.0.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--3.1.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--3.1.0--3.1.0next.sql
/usr/share/postgresql/12/extension/postgis_raster--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--3.1.0dev--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--3.1.0next--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--ANY--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--unpackaged--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_raster--unpackaged.sql
/usr/share/postgresql/12/extension/postgis_raster.control
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.0.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.0.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.0.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.0.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.0.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.0.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.0.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.0.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.1.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.1.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.1.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.1.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.1.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.1.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.1.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.1.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.1.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.1.9--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.2.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.2.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.2.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.2.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.2.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.2.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.2.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.2.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.2.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.3.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.3.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.3.10--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.3.11--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.3.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.3.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.3.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.3.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.3.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.3.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.3.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.3.9--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.4.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.4.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.4.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.4.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.4.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.4.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.4.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.4.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.4.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.4.9--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.5.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.5.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.5.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.5.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.5.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--2.5.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--3.0.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--3.0.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--3.0.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--3.0.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--3.1.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--3.1.0--3.1.0next.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--3.1.0dev--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--3.1.0next--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--ANY--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder--unpackaged--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_tiger_geocoder.control
/usr/share/postgresql/12/extension/postgis_topology--2.0.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.0.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.0.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.0.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.0.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.0.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.0.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.0.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.1.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.1.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.1.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.1.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.1.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.1.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.1.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.1.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.1.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.1.9--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.2.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.2.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.2.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.2.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.2.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.2.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.2.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.2.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.2.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.3.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.3.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.3.10--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.3.11--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.3.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.3.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.3.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.3.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.3.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.3.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.3.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.3.9--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.4.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.4.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.4.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.4.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.4.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.4.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.4.6--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.4.7--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.4.8--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.4.9--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.5.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.5.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.5.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.5.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.5.4--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--2.5.5--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--3.0.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--3.0.1--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--3.0.2--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--3.0.3--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--3.1.0--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--3.1.0--3.1.0next.sql
/usr/share/postgresql/12/extension/postgis_topology--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--3.1.0dev--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--3.1.0next--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--ANY--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--unpackaged--3.1.0.sql
/usr/share/postgresql/12/extension/postgis_topology--unpackaged.sql
/usr/share/postgresql/12/extension/postgis_topology.control
Content of postgis.control:
comment = 'PostGIS geometry and geography spatial types and functions'
default_version = '3.1.0'
module_pathname = '$libdir/postgis-3'
relocatable = false
Leaving this here for people using pgAdmin.
I tried to install PostGis via right-click Extensions -> CREATE
In the dialog I had no selection "postgis" just "postgis-3". I tried that and got the error message error extension postgis 3 has no installation script nor update path for version that lead me to this SO Post.
But using the SQL Tool instead of the Dialog worked!
right-click on your database
query tool
CREATE EXTENSION postgis CASCADE;
Old post, but I came across this today as I faced exactly the same problem.
I found that I had three different clusters online (from running pg_lsclusters) and that my psql session was connecting to a different one than postgis installed to. The postgis 3.1.4 extension setup files were going to my postgres 14 (/usr/share/postgresql/14/extension/) and psql was connecting to my postgres12 by default. Copying the setup files from one to the other didn't work.
At least I was able to identify the port using pg_lsclusters and pass the -p option to psql, then my script containing "CREATE EXTENSION postgis" ran fine.
Will comment again if I improve on this.
UPDATE: I've resolved to creating a file ~/.postgresqlrc to direct postgresql to default to the version I want (where postgis installed), containing contents:
14 main postgres
I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine?
I want to play with Python 3 while still being able to run 2.x scripts on the same machine.
The official solution for coexistence seems to be the Python Launcher for Windows, PEP 397 which was included in Python 3.3.0. Installing the release dumps py.exe and pyw.exe launchers into %SYSTEMROOT% (C:\Windows) which is then associated with py and pyw scripts, respectively.
In order to use the new launcher (without manually setting up your own associations to it), leave the "Register Extensions" option enabled. I'm not quite sure why, but on my machine it left Py 2.7 as the "default" (of the launcher).
Running scripts by calling them directly from the command line will route them through the launcher and parse the shebang (if it exists). You can also explicitly call the launcher and use switches: py -3 mypy2script.py.
All manner of shebangs seem to work
#!C:\Python33\python.exe
#!python3
#!/usr/bin/env python3
as well as wanton abuses
#! notepad.exe
Here's my setup:
Install both Python 2.7 and 3.4 with the windows installers.
Go to C:\Python34 (the default install path) and change python.exe to python3.exe
Edit your environment variables to include C:\Python27\;C:\Python27\Scripts\;C:\Python34\;C:\Python34\Scripts\;
Now in command line you can use python for 2.7 and python3 for 3.4.
From version 3.3 Python introduced Launcher for Windows utility https://docs.python.org/3/using/windows.html#python-launcher-for-windows.
So to be able to use multiple versions of Python:
install Python 2.x (x is any version you need)
install Python 3.x (x is any version you need also you have to have one version 3.x >= 3.3)
open Command Prompt
type py -2.x to launch Python 2.x
type py -3.x to launch Python 3.x
You can have both installed.
You should write this in front of your script:
#!/bin/env python2.7
or, eventually...
#!/bin/env python3.6
Update
My solution works perfectly with Unix, after a quick search on Google, here is the Windows solution:
#!c:/Python/python3_6.exe -u
Same thing: in front of your script.
Here is a neat and clean way to install Python2 & Python3 on windows.
https://datascience.com.co/how-to-install-python-2-7-and-3-6-in-windows-10-add-python-path-281e7eae62a
My case: I had to install Apache cassandra. I already had Python3 installed in my D: drive. With loads of development work under process i didn't wanted to mess my Python3 installation. And, i needed Python2 only for Apache cassandra.
So i took following steps:
Downloaded & Installed Python2.
Added Python2 entries to classpath (C:\Python27;C:\Python27\Scripts)
Modified python.exe to python2.exe (as shown in image below)
Now i am able to run both. For Python 2(python2 --version) & Python 3 (python --version).
So, my Python3 installation remained intact.
I'm using 2.5, 2.6, and 3.0 from the shell with one line batch scripts of the form:
:: The # symbol at the start turns off the prompt from displaying the command.
:: The % represents an argument, while the * means all of them.
#c:\programs\pythonX.Y\python.exe %*
Name them pythonX.Y.bat and put them somewhere in your PATH. Copy the file for the preferred minor version (i.e. the latest) to pythonX.bat. (E.g. copy python2.6.bat python2.bat.) Then you can use python2 file.py from anywhere.
However, this doesn't help or even affect the Windows file association situation. For that you'll need a launcher program that reads the #! line, and then associate that with .py and .pyw files.
When you add both to environment variables there will a be a conflict because the two executable have the same name: python.exe.
Just rename one of them. In my case I renamed it to python3.exe.
So when I run python it will execute python.exe which is 2.7
and when I run python3 it will execute python3.exe which is 3.6
Here you go...
winpylaunch.py
#
# Looks for a directive in the form: #! C:\Python30\python.exe
# The directive must start with #! and contain ".exe".
# This will be assumed to be the correct python interpreter to
# use to run the script ON WINDOWS. If no interpreter is
# found then the script will be run with 'python.exe'.
# ie: whatever one is found on the path.
# For example, in a script which is saved as utf-8 and which
# runs on Linux and Windows and uses the Python 2.6 interpreter...
#
# #!/usr/bin/python
# #!C:\Python26\python.exe
# # -*- coding: utf-8 -*-
#
# When run on Linux, Linux uses the /usr/bin/python. When run
# on Windows using winpylaunch.py it uses C:\Python26\python.exe.
#
# To set up the association add this to the registry...
#
# HKEY_CLASSES_ROOT\Python.File\shell\open\command
# (Default) REG_SZ = "C:\Python30\python.exe" S:\usr\bin\winpylaunch.py "%1" %*
#
# NOTE: winpylaunch.py itself works with either 2.6 and 3.0. Once
# this entry has been added python files can be run on the
# commandline and the use of winpylaunch.py will be transparent.
#
import subprocess
import sys
USAGE = """
USAGE: winpylaunch.py <script.py> [arg1] [arg2...]
"""
if __name__ == "__main__":
if len(sys.argv) > 1:
script = sys.argv[1]
args = sys.argv[2:]
if script.endswith(".py"):
interpreter = "python.exe" # Default to wherever it is found on the path.
lines = open(script).readlines()
for line in lines:
if line.startswith("#!") and line.find(".exe") != -1:
interpreter = line[2:].strip()
break
process = subprocess.Popen([interpreter] + [script] + args)
process.wait()
sys.exit()
print(USAGE)
I've just knocked this up on reading this thread (because it's what I was needing too). I have Pythons 2.6.1 and 3.0.1 on both Ubuntu and Windows. If it doesn't work for you post fixes here.
Try using Anaconda.
Using the concept of Anaconda environments, let’s say you need Python 3 to learn programming, but you don’t want to wipe out your Python 2.7 environment by updating Python. You can create and activate a new environment named "snakes" (or whatever you want), and install the latest version of Python 3 as follows:
conda create --name snakes python=3
Its simpler than it sounds, take a look at the intro page here: Getting Started with Anaconda
And then to handle your specific problem of having version 2.x and 3.x running side by side, see:
Managing Python Versions with Anaconda
Switching between Python 2 and Python 3 environments
As far as I know Python runs off of the commandline using the PATH variable as opposed to a registry setting.
So if you point to the correct version on your PATH you will use that. Remember to restart your command prompt to use the new PATH settings.
The Python installation normally associates .py, .pyw and .pyc files with the Python interpreter. So you can run a Python script either by double-clicking it in Explorer or by typing its name in a command-line window (so no need to type python scriptname.py, just scriptname.py will do).
If you want to manually change this association, you can edit these keys in the Windows registry:
HKEY_CLASSES_ROOT\Python.File\shell\open\command
HKEY_CLASSES_ROOT\Python.NoConFile\shell\open\command
HKEY_CLASSES_ROOT\Python.CompiledFile\shell\open\command
Python Launcher
People have been working on a Python launcher for Windows: a lightweight program associated with .py and .pyw files which would look for a "shebang" line (similar to Linux et al) on the first line, and launch Python 2.x or 3.x as required. See "A Python Launcher for Windows" blog post for details.
Here is how to run Python 2 and 3 on the same machine
install Python 2.x
install Python 3.x
Start Powershell
Type Python -2 to launch Python 2.x
Type Python -3 to launch Python 3.x
The Python Launcher for Windows was embedded into Python since Version 3.3, as promised in 2011 when the Stand alone first made its debut:
Python Launcher for Windows
Easy-peasy ,after installing both the python versions add the paths to the environment variables ;see. Then go to python 2 and python 3 folders and rename them to python2 and python3 respectively as shown and . Now in cmd type python2 or python3 to use your required version see .
I think there is an option to setup the windows file association for .py files in the installer. Uncheck it and you should be fine.
If not, you can easily re-associate .py files with the previous version. The simplest way is to right click on a .py file, select "open with" / "choose program". On the dialog that appears, select or browse to the version of python you want to use by default, and check the "always use this program to open this kind of file" checkbox.
You should make sure that the PATH environment variable doesn't contain both python.exe files ( add the one you're currently using to run scripts on a day to day basis ) , or do as Kniht suggested with the batch files .
Aside from that , I don't see why not .
P.S : I have 2.6 installed as my "primary" python and 3.0 as my "play" python . The 2.6 is included in the PATH . Everything works fine .
Before I courageously installed both simultaneously, I had so many questions. If I give python will it go to py3 when i want py2? pip/virtualenv will happen under py2/3?
It seems to be very simple now.
Just blindly install both of them. Make sure you get the right type(x64/x32).
While/after installing make sure you add to the path to your environment variables.
[ENVIRONMENT]::SETENVIRONMENTVARIABLE("PATH", "$ENV:PATH;C:\PYTHONx", "USER")
Replace the x in the command above to set the path.
Then go to both the folders.
Navigate to
python3.6/Scripts/
and rename pip to pip3.
If pip3 already exists delete the pip. This will make sure that just pip will run under python2. You can verify by:
pip --version
In case you want to use pip with python3 then just use
pip3 install
You can similarly do the same to python file and others.
Cheers!
I had the same problem where I wanted to use python3 for most work but IDA pro required python2. SO, here's what I did.
I first created 3 variables in the user environment variable as follows:
PYTHON_ACTIVE : This is initially empty
HOME_PYTHON27 : Has a path to a folder where Python 2 is installed. Eg. ";/scripts;"
HOME_PYTHON38 : Similar to python 2, this variable contains a path to python 3 folders.
Now I added
%PYTHON_ACTIVE%
to PATH variable. So, basically saying that whatever this "PYTHON_ACTIVE" contains is the active python. We programmatically change the contains of "PYTHON_ACTIVE" to switch python version.
Here is the example script:
:: This batch file is used to switch between python 2 and 3.
#ECHO OFF
set /p choice= "Please enter '27' for python 2.7 , '38' for python 3.8 : "
IF %choice%==27 (
setx PYTHON_ACTIVE %HOME_PYTHON27%
)
IF %choice%==38 (
setx PYTHON_ACTIVE %HOME_PYTHON38%
)
PAUSE
This script takes python version as input and accordingly copies HOME_PYTHON27 or HOME_PYTHON38 to PYTHON_ACTIVE. Thus changing the global Python version.
I would assume so, I have Python 2.4, 2.5 and 2.6 installed side-by-side on the same computer.
I am just starting out with python now. I'm reading Zed Shaw's book "Learn Python the Hard Way" which requires python version 2.x but am also taking a class that requires python 3.x
So here is what I did.
Download python 2.7
run power shell (should already be installed on windows)
run python IN POWERSHELL (if it doesn't recognize then go to step 4)
Only if powershell doesn't recognize python 2.7 type in the following:
"[ENVIRONMENT]::SETENVIRONMENTVARIABLE("PATH", "$ENV:PATH;C:\PYTHON27", "USER")"
(no outside quotes)
Now type python and you should see it say python 2.7 blah blah blah
NOW for python 3.x
Simple, python 3.x download comes with python for windows app. SO simply pin the Python for Windows app to your task bar, or create shortcut to the desktop and you are done!
Open Python for Windows for 3.x
Open Powershell for python 2.x
I hope this helps!
Hmm..I did this right now by just downloading Python 3.6.5 for Windows at https://www.python.org/downloads/release/python-365/ and made sure that the launcher would be installed. Then, I followed the instructions for using python 2 and python 3. Restart the command prompt and then use py -2.7 to use Python 2 and py or py -3.6 to use Python 3. You can also use pip2 for Python 2's pip and pip for Python 3's pip.
I've found a lot of posts on Macports/Django install issues but none seem to quite address my situation.
Installed Django using Macports from the command line using
sudo port install py27-django
This seemed to work fine. I opened up IDLE and was able to import django. The following bit of code
import django
from django.core import management
print django.VERSION
returns
(1, 5, 1, 'final', 0)
Which I take to mean I have the final version of Django 1.5.1 installed. So, all seems to be well.
However, now I switch over to my Django tutorial to get learning and I am asked to type this into the command line to confirm that Django is installed:
python -c "import django; print(django.get_version())"
and get the following error:
> File "<string>", line 1, in <module> ImportError: No module named
> django
Some other bits of data. Here's my $PATH:
/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
Finally, the command
django-admin.py startproject mysite
returns
-bash: django-admin.py: command not found
But the command
django-admin-2.7.py startproject mysite
works (creates a new directory called mysite in the working directory). I read somehwere that Macports renames the django-admin file.
I've only been working with Unix for a few weeks so this is a bit confusing. It seems like I have Django on my system, but perhaps the python I am trying to access from my command line is a different python from that which Macports uses.
Any help appreciated!
Dennis
You will need to set your PYTHONPATH environment variable from your terminal to reference your django install. IDLE probably did this for you, but in another shell you'll need to set it. You can set it in your terminal permanently by setting it in ~/.bashrc or ~/.bash_profile (or whatever your terminal shell is).
Your PATH starts with /Library/Frameworks/Python.framework/Versions/2.7/bin so when you type python you get the python in that directory which is the Apple supplied one nut you have installed Django for the Macports one so python does not see it.
To fix you need to have /opt/local/bin earlier on the path than the /Library one. even better remove that /Library entry and use port select python ... to choose which python to run the Macports 2.7 or Apple's or others
As for the django-admin-2.7.py issue, Macports allows you to have several versions of python at once so code depending on eth version has the version add into the script names e.g. you could have a django-admin-2.6.py as well if you installed the py26-django package. This also applies to python itself however python also adds into the port select mechanism so you set a default version.
I am working on MacOS Lion. I have successfully set up the KyngChaos libraries for Postgres and PostGIS, as per the official instructions with no problems.
I've reached the section on creating a spatial database template, and now I'm hitting a problem:
$ psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
/postgis.sql: No such file or directory
How can I debug this? Where does postgis.sql come from in the first place?
UPDATE:
I just made sure that POSTGIS_SQL_PATH was actually set, as follows:
$ POSTGIS_SQL_PATH=`pg_config --sharedir`/contrib/postgis-1.5
$ echo $POSTGIS_SQL_PATH
/usr/local/Cellar/postgresql/9.1.3/share/postgresql/contrib/postgis-1.5
$ psql -d template_postgis -f $POSTGIS_SQL_PATH/postgis.sql
/usr/local/Cellar/postgresql/9.1.3/share/postgresql/contrib/postgis-1.5/postgis.sql: No such file or directory
It looks as though /usr/local/Cellar/postgresql/9.1.3/share/postgresql/ exists but there is no contrib directory below it. Where does this come from?
It seems like you are not finding postgis. Start by searching for postgis.sql. If it is not found then install postgis. If it is found then set your path appropriately.
I have installed OSQA using the wiki script (webfaction). Now I want to compile a message file and I get the following error:
django msgfmt command not found
The command + output:
$ ls
apache2 bin lib osqa osqa.wsgi wfinstall.log
[rijkers#web303 hozburo]$ cd osqa
[rijkers#web303 osqa]$ ../bin/django-admin.py compilemessages
processing file django.po in /home/rijkers/webapps/hozburo/osqa/locale/bg/LC_MESSAGES sh: msgfmt: command not found
msgfmt is a program. You need to have it installed on your system for this compilemessages command to work (at least as far as I know it).
You are probably on some *nix system, so it shouldn't be very hard. Just use your package manager and install gettext package (or similar).