Mapnik install issue

1,395 views
Skip to first unread message

richar...@spatialdays.com

unread,
Apr 28, 2012, 7:37:45 PM4/28/12
to mapnik
Hi all,

I am a newbie to Python, this group and mapnik so please go easy on
me!

Just installed the mapnik 2.0.1 binary download on my Windows 7
machine (installed it at C:\mapnik-2.0.1rc0), updated the path for it
using a .pth file (I used C:\mapnik-2.0.1rc0\python\2.7\site-packages
because C:\mapnik-2.0.1rc0\lib which was recommended didn't work)
which I put in my C:\Python27 dir, checked sys.path (path appeared
ok), and tried:

import mapnik

and I got: "ImportError: DLL load failed: The specified module could
not be found."

Looking in the __init__.py file there is a line near the top:

from _mapnik import *

This didn't look right so I deleted the underscore:

from mapnik import *

This got me further but now I get:

"Traceback (most recent call last):
File "C:\mapnik-2.0.1rc0\python\2.7\site-packages\mapnik
\__init__.py", line 46, in <module>
from mapnik import *
File "C:\mapnik-2.0.1rc0\python\2.7\site-packages\mapnik
\__init__.py", line 49, in <module>
import printing
File "C:\mapnik-2.0.1rc0\python\2.7\site-packages\mapnik
\printing.py", line 20, in <module>
from . import render, Map, Box2d, MemoryDatasource, Layer,
Feature, Projection, ProjTransform, Coord, Style, Rule, Geometry2d
ImportError: cannot import name render"

It appears to be unhappy with line 20 of printing.py:

from . import render

Does "render" still exist in Mapnik 2.0.1?

Please could someone tell me where I am going wrong here - I really
want to actually start using Mapnik now!!

Thanks in advance.

Richard Oates

Dane Springmeyer

unread,
Apr 29, 2012, 11:15:38 PM4/29/12
to map...@googlegroups.com
Hi Richard,

On Apr 28, 2012, at 7:37 PM, richar...@spatialdays.com wrote:

> Hi all,
>
> I am a newbie to Python, this group and mapnik so please go easy on
> me!
>
> Just installed the mapnik 2.0.1 binary download on my Windows 7
> machine (installed it at C:\mapnik-2.0.1rc0), updated the path for it
> using a .pth file (I used C:\mapnik-2.0.1rc0\python\2.7\site-packages
> because C:\mapnik-2.0.1rc0\lib which was recommended didn't work)

you need to point PATH at the 'lib' directory. That is not optional - it is so that mapnik.dll can be found by the bindings.

Using a .pth should work (so python can find the bindings themselves), but ideally you could follow the instructions and just use PYTHONPATH ?

> which I put in my C:\Python27 dir, checked sys.path (path appeared
> ok), and tried:
>
> import mapnik
>
> and I got: "ImportError: DLL load failed: The specified module could
> not be found."

That means that the bindings could not find mapnik.dll, likely because you need to put its directory on your PATH.

>
> Looking in the __init__.py file there is a line near the top:
>
> from _mapnik import *
>
> This didn't look right so I deleted the underscore:
>

The underscore is correct. It is the name of the C++ part of the python bindings. The __init__.py imports all the core functions and classes from the _mapnik.pyd.

richar...@spatialdays.com

unread,
Apr 30, 2012, 5:05:38 AM4/30/12
to mapnik
Hi all,

Thanks for the reply.

I did what Dane suggested and put the underscore back in the
__init__.py file, added C:\mapnik-2.0.1rc0\lib to PYTHONPATH (and
checked that it contains the mapnik.dll which it does) and deleted
the .pth file I had from C:\Python27.

I then restarted Python and tried:

import mapnik

I got:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named mapnik

so it appears it still can't find the module/see the dll?

FYI, I have used the Python and mapnik versions recommended on
http://mapnik.org/news/2011/11/29/windows-binaries-progress but I note
there is a 64bit warning on there and my machine is a 64bit Windows 7
machine. Do you think that could be the problem? The error message
doesn't suggest that?

Any ideas?

Thanks in advance

Richard Oates




On Apr 30, 4:15 am, Dane Springmeyer <d...@dbsgeo.com> wrote:
> Hi Richard,
>

richar...@spatialdays.com

unread,
May 8, 2012, 5:42:36 PM5/8/12
to mapnik
Hi all,

For the record, I am pleased to say this install issue has been
resolved and mapnik is now working for me on 64bit Windows 7.

It turned out it was a simple matter of not completely following the
setup instructions because these instructions are kind of mixed up
with instructions relating to running the demo, which I was not
interested in doing so I missed a crucial line!

I set the PYTHONPATH user variable (set PYTHONPATH=%PYTHONPATH%;c:
\mapnik-2.0.1rc0\python\2.7\site-packages;) as per the instructions on
http://mapnik.org/news/2011/11/29/windows-binaries-progress but I
failed to also set the PATH system variable (set PATH=%PATH%;c:
\mapnik-2.0.1rc0\lib).

Once both these variables were set, Mapnik worked first time.

Thanks for all help received.

Richard



On Apr 30, 10:05 am, richard.oa...@spatialdays.com wrote:
> Hi all,
>
> Thanks for the reply.
>
> I did what Dane suggested and put the underscore back in the
> __init__.py file, added C:\mapnik-2.0.1rc0\lib to PYTHONPATH (and
> checked that it contains the mapnik.dll which it does) and deleted
> the .pth file I had from C:\Python27.
>
> I then restarted Python and tried:
>
> import mapnik
>
> I got:
>
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> ImportError: No module named mapnik
>
> so it appears it still can't find the module/see the dll?
>
> FYI, I have used the Python and mapnik versions recommended onhttp://mapnik.org/news/2011/11/29/windows-binaries-progressbut I note

张丹青

unread,
Oct 7, 2013, 7:47:00 AM10/7/13
to map...@googlegroups.com

Hi Richard!

I am wondering if the mapnik 2.0.1 can work on the windows 7,for I have already installed the mapnik 2.2.0 and its turns out:DLL load failed: %1
which means this can only be installed on win 7 32 bit. I am wondering if 2.0.1 version will help.Many thanks!

Danqing
在 2012年4月29日星期日UTC+8上午7时37分45秒,richar...@spatialdays.com写道:
Reply all
Reply to author
Forward
0 new messages