geodjango tutorial failure on containerized setup

Skip to first unread message


Feb 19, 2016, 2:09:42 AM2/19/16
to geodjango
I've created a set of docker containers which can be run with docker-compose that support all the dependencies for geodjango. 
You can get that here:

However, the tutorial is not working properly, when I run it fails to save all the shapes. Specifically, it always fails after Mayotte.

This very well could be something I missed in the setup of my containers, but I'm at a loss as for what to check next. Any suggestions would be great. I hope this docker-compose setup will be of general use.

Here's the relevant parts of the output from python shell

>>> from world import load
Saved: Antigua and Barbuda
Saved: Algeria
Saved: Azerbaijan
Saved: Albania
Saved: Montenegro
Saved: Mayotte
Failed to save the feature (id: 141) into the model with the keyword arguments:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/django/core/management/commands/", line 69, in handle
  File "/usr/local/lib/python3.5/site-packages/django/core/management/commands/", line 61, in run_shell
    raise ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/django/contrib/gis/utils/", line 577, in _save
    stream.write('%s: %s\n' % ('Updated' if is_update else 'Saved', m))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 7-8: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/app/world/", line 28, in run, verbose=verbose)
  File "/usr/local/lib/python3.5/site-packages/django/contrib/gis/utils/", line 627, in save
  File "/usr/local/lib/python3.5/", line 30, in inner
    return func(*args, **kwds)
  File "/usr/local/lib/python3.5/site-packages/django/contrib/gis/utils/", line 586, in _save
    stream.write('%s\n' % kwargs)
UnicodeEncodeError: 'ascii' codec can't encode character '\xc3' in position 135: ordinal not in range(128)


Claude Paroz

Feb 19, 2016, 2:58:42 AM2/19/16
Hello Patrick,

Could you try removing the "encoding='iso-8859-1'" part in the
LayerMapping constructor?
Could you also tell us which version of GDAL are you using?

It may be that with recent GDAL versions, character decoding happens at
a lower level.


Le 19. 02. 16 01:39, Patrick a écrit :


Feb 19, 2016, 1:38:42 PM2/19/16
to geodjango
Thanks for the reply Claude.

Unfortunately, your suggestion didn't work, it failed in exactly the same way.

Versions are as follows:


Container is based on python 3.5 which is based on debian:jessie and I'm installing all of the recommended libraries.

apt-get update && apt-get -y install \
    binutils \
    libproj-dev \
    gdal-bin \
    libgeoip1 \
    gdal-bin \

Thanks again!

Nov 15, 2017, 3:32:03 AM11/15/17
to geodjango
Hi Patrick,

I am facing the same problem with the installation, but it seems to be related to the database encoding, did you see this post:!topic/geodjango/Imkq2DDI7qg? Have you fixed the problem?

Reply all
Reply to author
0 new messages