geodjango tutorial load.run() failure on containerized setup

88 views
Skip to first unread message

Patrick

unread,
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 load.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 manage.py shell

>>> from world import load
>>> load.run()
Saved: Antigua and Barbuda
Saved: Algeria
Saved: Azerbaijan
Saved: Albania
...
.SNIP.
...
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/shell.py", line 69, in handle
    self.run_shell(shell=options['interface'])
  File "/usr/local/lib/python3.5/site-packages/django/core/management/commands/shell.py", line 61, in run_shell
    raise ImportError
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/layermapping.py", 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/load.py", line 28, in run
    lm.save(strict=True, verbose=verbose)
  File "/usr/local/lib/python3.5/site-packages/django/contrib/gis/utils/layermapping.py", line 627, in save
    _save()
  File "/usr/local/lib/python3.5/contextlib.py", line 30, in inner
    return func(*args, **kwds)
  File "/usr/local/lib/python3.5/site-packages/django/contrib/gis/utils/layermapping.py", 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)



Thanks,
-p

Claude Paroz

unread,
Feb 19, 2016, 2:58:42 AM2/19/16
to geod...@googlegroups.com
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.

Claude
--
www.2xlibre.net

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

Patrick

unread,
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:

proj-4.9.1.tar.gz
geos-3.4.2.tar.bz2 
gdal-1.11.2.tar.gz

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 \
    python-gdal

Thanks again!
-p

eduard...@gmail.com

unread,
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: https://groups.google.com/forum/#!topic/geodjango/Imkq2DDI7qg? Have you fixed the problem?

Thanks,
Eduardo
Reply all
Reply to author
Forward
0 new messages