1

This question is similar to How to have PostGIS 2.1 and the Python osgeo library installed together without compiling from source?

but I couldn't figure out how to ask a follow-up question.

I am trying to get PostgreSQL + PostGIS + MapServer + Python-MapScript working on Ubuntu 12.04 LTS, for a Geo-Django site. In the past, this has worked wonderfully (was still working in April of 2014), however something has changed, and I'm now getting an error regarding gdal compatibility:

The following packages have unmet dependencies: postgresql-9.1-postgis : Depends: libgdal1 (>= 1.9.0) but it is not going to be installed E: Unable to correct problems, you have held broken packages.

After a fair bit of searching, I came across Brian (cokrzys)'s answer to the post above. I followed his instructions on a clean install of Ubuntu 12.04, and was subsequently able to create the PostGIS templates in PostgreSQL 9.3. However, when I then try to install python-mapscript, I get the following message:

The following packages will be REMOVED: libgdal1 postgis postgresql-9.3-postgis-2.1

So, the problem is that it does not appear that I can have both the postgis libraries and the python-mapscript libraries installed at the same time.

Honestly, I don't care what version of PostgreSQL / PostGIS / MapServer I use, so long as I can get it running on Ubuntu 12.04.

Has anyone had any luck with this?


@Mark helped me to finally got this working as follows:

#!/usr/bin/env bash
###################################################################
# Install GDAL, MapServer, etc. first
###################################################################
echo "Y" | sudo apt-get install python-software-properties
echo "Y" | sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update
echo "Y" | sudo apt-get install mapserver-bin
echo "Y" | sudo apt-get install gdal-bin
echo "Y" | sudo apt-get install cgi-mapserver
echo "Y" | sudo apt-get install python-gdal
echo "Y" | sudo apt-get install python-mapscript
echo "Y" | sudo apt-get install python-gdal

###################################################################
# Then Install PostgreSQL9.1, PostGIS 9.1
###################################################################
echo "Y" | sudo apt-get install postgresql-9.1
echo "Y" | sudo apt-get install postgresql-client-9.1
echo "Y" | sudo apt-get install postgresql-server-dev-9.1
echo "Y" | sudo apt-get install postgresql-plperl-9.1
echo "Y" | sudo apt-get install postgresql-9.1-postgis-2.0
  • See My answer to a Previous Question here – Mark Cupitt Sep 7 '14 at 5:07
  • btw, instead of echo "Y" you can just use the -y flag on apt-get and apt-add. For instance sudo apt-get install -y python-software-properties. This will also prevent prompts. – yellowcap Sep 26 '14 at 13:02
  • Thanks! Didn't know about the -y flag. So much better. – svw Sep 27 '14 at 23:36
2

From a clean Ubuntu 12.04 Precise install I was able to get it to work with this:

echo 'deb http://ppa.launchpad.net/ubuntugis/ppa/ubuntu precise main' | sudo tee -a /etc/apt/sources.list
echo 'deb-src http://ppa.launchpad.net/ubuntugis/ppa/ubuntu precise main' | sudo tee -a /etc/apt/sources.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 314DF160
sudo apt-get update
sudo apt-get install -y postgresql-server-dev-9.1 postgis python-mapscript python-gdal

For more up-to-date gis packages use the unstable repository

echo 'deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu precise main' | sudo tee -a /etc/apt/sources.list
echo 'deb-src http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu precise main' | sudo tee -a /etc/apt/sources.list

This also works for Ubuntu 14.04 Trusty, just replace precise with trusty when adding the ubuntugis repos. Then you can also install postgres 9.3 instead of 9.1. So on Trusty use:

sudo apt-get install -y postgresql-server-dev-9.3 postgis python-mapscript python-gdal

The two references for installing this I used were

http://trac.osgeo.org/ubuntugis/wiki/UbuntuGISRepository

https://launchpad.net/~ubuntugis/+archive/ubuntu/ppa/

Also, if you want to use the postgis raster driver through mapscript, it is worth trying to install the latest GDAL version, as it has essential improvements on the raster driver (its much faster and more stable). So in that case I would recommend the unstable repo, in my work so far I did not run into problems due to the "unstable" name.

  • Thanks for this! I have a working solution now using the older packages, but will definitely refer to this in the future if/when I upgrade to Trusty. By chance, do you understand the dependency relationship between 1. gdal, 2. postgres/postgis, and 3. mapscript/mapserver? Can I just upgrade 1 w/o breaking 2 & 3? And if this is the case, why, in past experiments, when I installed postgres/postgis 9.3 and then tried to install mapscript, I got the "The following packages will be REMOVED: libgdal1 postgis postgresql-9.3-postgis-2.1" error? I'm having a hard time inferring their relationships. – svw Sep 27 '14 at 23:49
  • I am not sure about this, but my guess is that you get these errors because you have some libraries already installed. If that is the case these pre-installed libraries (libgda, postgis) might be out of sync because they were not installed from ubuntugis. PostGIS and mapserver both depend on gdal so if you re-install gdal (through python-gdal's dependencies for instance), it might remove the previous gdal install and then also its dependencies, for instance postgis. – yellowcap Sep 29 '14 at 6:48
1

Installing PostGIS 2.1 and PostgreSQL 9.3 on Ubuntu 12.04 etc. from the PostgreSQL Apt Repository can be found here:

http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS21UbuntuPGSQL93Apt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.