В общем вот оригинальный файл
__init__.py, который лежит в каталоге
D:\python\Lib\site-packages\mapnik#
# This file is part of Mapnik (C++/Python mapping toolkit)
# Copyright (C) 2005 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
import os
if os.name != "nt" :
from sys import getdlopenflags,setdlopenflags
try:
from dl import RTLD_NOW, RTLD_GLOBAL
except ImportError:
RTLD_NOW = 2
RTLD_GLOBAL = 256
flags = getdlopenflags()
setdlopenflags(RTLD_NOW | RTLD_GLOBAL)
from _mapnik import *
from paths import inputpluginspath, fontscollectionpath
# The base Boost.Python class
BoostPythonMetaclass = Coord.__class__
class _injector( object ):
class __metaclass__( BoostPythonMetaclass ):
def __init__( self, name, bases, dict ):
for b in bases:
if type(b) not in ( self, type ):
for k,v in dict.items():
setattr(b,k,v)
return type.__init__( self, name, bases, dict )
class _Coord(Coord,_injector):
def __repr__( self ):
return 'Coord(%s,%s)' % ( self.x, self.y )
class _Envelope(Envelope,_injector):
def __repr__(self):
return 'Envelope(%s,%s,%s,%s)' % \
(self.minx,self.miny,self.maxx,self.maxy)
class _Projection(Projection,_injector):
def forward(self,obj):
return forward_(obj,self)
def inverse(self,obj):
return inverse_(obj,self)
class _Datasource(Datasource,_injector):
def describe(self):
return Describe(self)
def Datasource (**keywords):
return CreateDatasource(keywords)
# convinience factory methods
def Shapefile(**keywords):
keywords['type'] = 'shape'
return CreateDatasource(keywords)
def PostGIS(**keywords):
keywords['type'] = 'postgis'
return CreateDatasource(keywords)
def Raster(**keywords):
keywords['type'] = 'raster'
return CreateDatasource(keywords)
def Gdal (**keywords):
keywords['type'] = 'gdal'
return CreateDatasource(keywords)
#register datasources
from mapnik import DatasourceCache
DatasourceCache.instance().register_datasources('%s' % inputpluginspath)
#register some fonts
from mapnik import FontEngine
from glob import glob
fonts = glob('%s/*.ttf' % fontscollectionpath)
if len( fonts ) == 0:
print "### WARNING: No ttf files found in '%s'." % fontscollectionpath
else:
map(FontEngine.register_font, fonts)
if os.name != "nt" :
#set dlopen flags back to the original
setdlopenflags(flags)
Я скачал программу
Mapnik и четко следовал инструкциям (а там было сказано просто распаковать архив и копировать папку mapnik в папку куда установлен python, в Lib\site-packages - что собственно я и сделал). Далее говорится что нужно через консоль запустить питон и напечатать
from mapnik import *, что я и сделал.
Но сперва получил ошибку:
>>> from mapnik import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\python\lib\site-packages\mapnik\__init__.py", line 33, in <module>
from _mapnik import *
ImportError: DLL load failed: ═х эрщфхэ єърчрээ√щ ьюфєы№.
Тогда я заменил строчку
from _mapnik import * на
from mapnik import * и проблема исчезла, но пришла другая, о которой я и написал выше.