Opened 5 years ago

Last modified 4 years ago

#30933 closed Cleanup/optimization

Update installation instructions for GeoDjango dependencies on Windows. — at Version 5

Reported by: Adam Starrh Owned by: nobody
Component: Documentation Version: 2.2
Severity: Normal Keywords: geodjango, installation, windows
Cc: Carlton Gibson Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Nick Pope)

I'm setting GeoDjango up on Windows and discovered that GDAL is (at least currently) incompatible with 64-bit Python. Using 32-bit Python and 32-bit OSGeo4Win, I was finally able to get it working. I suggest this be mentioned in the docs to circumvent future headaches for other users.

Pull request:
https://github.com/django/django/pull/11995


The installation instructions for dependencies of GeoDjango on Windows are outdated.

Issues that need to be addressed include:

  • It seems that there may be some as yet undetermined issue wit 64-bit setups.
  • Not referencing only 9.x versions of PostgreSQL which are > 3 years old.
  • Consider referring to other geospatial database backends. Why should Windows users be forced to use PostGIS?
  • Replace outdated instructions for installation of psycopg2. We have binary wheels now that are more up to date.
  • Using OSGeo4W can lead to a newer version of GEOS than is supported by Django with no option to downgrade.
    • Consider installing individual dependencies for GDAL, GEOS & Proj.

Change History (5)

comment:1 by Adam Starrh, 5 years ago

Basically, this has happened to me a few times over the years. As a casual programmer, when following the setup docs I habitually install the 64-bit versions of everything because I figure they should match the OS/chipset. Inevitably, something fails mysteriously and I spend a lot of time trying to figure out the problem before converting everything over to 32-bit where things end up running more smoothly. Because it isn't an obvious problem, and because it seems to manifest itself in different ways, it takes a while to realize each time.

I was unable to run migrations after following the setup instructions on a fresh installation of Windows 10 and choosing the 64-bit versions of everything. I started over, this time choosing the 32-bit installations of python and OSGeo4Win, and everything worked smoothly.

This is not the first time I've had this experience. It would really be helpful as a novice programmer to at least be advised that the 64-bit version of Python may be problematic and will likely require steps that are outside the scope of the installation instructions if the user is to ultimately get it working.

comment:2 by Nick Pope, 5 years ago

Description: modified (diff)
Keywords: geodjango installation windows added
Needs documentation: set
Summary: Users need to be directed to install 32-bit Python for GeoDjangoUpdate installation instructions for GeoDjango dependencies on Windows.
Triage Stage: UnreviewedAccepted

So as I said on the PR, I do not feel that we should be encouraging users to install 32-bit. It seems like a backward step and I would rather we address making this work for 64-bit.
(I will admit that I don't use Windows, but I will endeavour to help where I can.)

So my understanding is that the documentation for installing dependencies for GeoDjango on Windows is at https://docs.djangoproject.com/en/stable/ref/contrib/gis/install/#windows.

The first requirement there is to install Python on Windows by following https://docs.djangoproject.com/en/stable/howto/windows/. Django 2.2 doesn't currently support the recently release 3.8, so let's go with 3.7.5 available from https://www.python.org/downloads/release/python-375/.

I note that the next steps suggests is that Windows users ought to be using PostgreSQL & PostGIS. This seems a bit restrictive as I'm sure the other geospatial database backends will work. But let's run with it. (I note that the documentation here ought to be updated to drop references to 9.x - version 10, 11 and 12 are available, so 9.6 is >3 years old.) Django 2.2 only supports up to 11, so let's go with 11.5, available from https://www.enterprisedb.com/downloads/postgres-postgresql-downloads. I note that EnterpriseDB have stopped providing 32-bit builds for Windows for PostgreSQL >= 11. I will assume at this stage that the instructions for PostGIS are the same or similar to those described.

According to the documentation, we will also need the latest version of psycopg2 from http://www.stickpeople.com/projects/python/win-psycopg/. Unfortunately that page no longer seems to work for me and times out. The Internet Archive Wayback Machine gives this version of the page, but the latest version there is only built for Python 3.6 and is psycopg2 2.6.2 when 2.8.4 is available. I would suggest that this documentation is updated to point to https://www.lfd.uci.edu/~gohlke/pythonlibs/#psycopg or, better yet, recommend installing psycopg2-binary from PyPI which wasn't available when this was written."

Next we come to OSGeo4W. The instructions point us to https://trac.osgeo.org/osgeo4w/ and using the 64-bit link we get an installer. I note the following restrictions under the "Notes" heading:

  • "32bit/64bit don't contain the same set of packages/versions ​(compare) (purple is 32 bit only)"
  • "Don't blindly do a full install in Advanced mode. Some components require third party additions that need to be installed manually (see the wiki page of the package). Without the additions the components might renderer the installation unuseable."

So after all of that I would expect that you are using the following installers:

For OSGeo4W I presume that you are using "Express Install" as instructed and not "Advanced mode". I don't know if that could cause any problems. There is also a problem that you have stumbled into that OSGeo4W installs a newer version of GDAL than Django 2.2 officially supports. This does make me wonder whether we'd be better off documenting installation of the actual dependencies of GeoDjango - that is GDAL, GEOS and Proj - although some of those just point back to OSGeo4W :(

We may also be bumping into issues with some packages compiled with MSVC and others with MinGW64. Do you have a specific error message or traceback, by the way?

Based on the above, I've updated this ticket to reflect the need for a wider review of the installation of dependencies for GeoDjango on Windows.

Last edited 5 years ago by Nick Pope (previous) (diff)

comment:3 by Mariusz Felisiak, 5 years ago

Nick, I still don't see where is an issue, except that http://www.stickpeople.com/projects/python/win-psycopg/ link is outdated.

There is also a problem that you have stumbled into that OSGeo4W installs a newer version of GDAL than Django 2.2 officially supports

I don't think that is true, OSGeo4W contains: gdal200dll, gdal201dll, gdal202dll, gdal203dll all of them are supported by Django 2.2.

It can be hard to fix an issue without details.

comment:4 by Carlton Gibson, 5 years ago

Cc: Carlton Gibson added

in reply to:  3 comment:5 by Nick Pope, 5 years ago

Description: modified (diff)

Replying to felixxm:

Nick, I still don't see where is an issue, except that http://www.stickpeople.com/projects/python/win-psycopg/ link is outdated.

That and referring to PostgreSQL 9.x seems overly restrictive. There haven't been a great many updates to this section of the documentation other than cosmetic in years and my impression from my comment above is that it could be made easier.

There is also a problem that you have stumbled into that OSGeo4W installs a newer version of GDAL than Django 2.2 officially supports

I don't think that is true, OSGeo4W contains: gdal200dll, gdal201dll, gdal202dll, gdal203dll all of them are supported by Django 2.2.

I was alluding to the comments starting at https://github.com/django/django/pull/10962#issuecomment-548004287, but if it installs the older versions too, then ...

It can be hard to fix an issue without details.

Indeed. I asked for some more details at the end...

Anyway. As I said, I don't use Windows. And I feel like I'm being unhelpful here, so I'll back off.

Note: See TracTickets for help on using tickets.
Back to Top