Closed Nacktiv closed 6 years ago
I tried this. But when I do "import mapnik" I get errors:
c:\mapnik-sdk\python\2.7\site-packages\mapnik__init__.py::74 RunTimeWarning: to-Python converter for class std::shared_ptr<struct mapnik::geometry::geometry
I get the same error five times.
I solved this problem by running "del mapnik" before "import mapnik" to remove the 2.2 version.
The demo works!
@Wolfgang16 doesnt it work with python 3.6?
Python@3.x
was never supported by mapnik
on Windows.
Sorry to let you know but Windows support for mapnik
has been dropped:
https://github.com/mapbox/windows-builds#deprecated
Since I didn't find any guide, I tried it myself, without knowing whether it will work. It took me more than 1 full day reading repositories, searching binaries, dealing with errors, tracing dll's, jumping through paths. Now I try to condense that down to a few lines. Since I am not a programmer, I understand only partially whats written here. So may be somebody with more insight could check my writings.
Install Visual C++ Redistributable for Visual Studio 2015 x86
Install latest Python 2.7 32-bit, don't try 64-bit. See mapnik/python-mapnik#145
Get https://mapnik.s3.amazonaws.com/dist/dev/mapnik-win-sdk-v3.0.11-x86-14.0.7z There is no download page for the windows binaries. You can also get other versions by changing manually the version number in the link, but unfortunately its not possible to use later releases because of missing python dependencies due to a compiler bug #92
unzip to
C:\prog\mapnik-v3.0.11
or whatever you want, but its safer when your path doesn't contain spaces.delete 'include' path, it contains 12000 useless files
check
C:\prog\mapnik-v3.0.11\python\2.7\site-packages\mapnik\_mapnik.pyd
must be there. These are the python dependencies.In
C:\prog\mapnik-v3.0.11\python\2.7\site-packages\mapnik\paths.py
edit Line 2 intomapniklibpath = 'C:\prog\mapnik-v3.0.11/lib/mapnik'
open Console in
C:\prog\mapnik-v3.0.11
and runset-env-vars.bat
run python by typing
C:\python27\python
and at the python prompt enterimport mapnik
If there is no error, you almost did it. Nowexit()
pythonGenerate some small demo maps by typing
cd demo\python
andC:\python27\python rundemo.py
Ignore the 5 warnings. Check the images.It is a good idea to add that and the python path in the
set-env-vars.bat
scriptCreate an icon with the command
C:\Windows\System32\cmd.exe /k C:\prog\mapnik-v3.0.11\set-env-vars.bat
with working directoryC:\prog\mapnik-v3.0.11\demo\python
Clicking on it you can start the console with an mapnik 3 working environment which at first checks whether everything is fine.
When you now check out one of the examples styling a map via python code made for mapnik 2, you might encounter some errors, because the polygonsymbolizers, linesymbolizers or textsymbolizers don't work properly in mapnik 3. See mapnik/python-mapnik#7. Recommended way to load a style is to use xml stylesheets instead.
Good luck
EDIT 02.Okt.2017 Now after a while this refused to work. It turned out that the redistributable files for Visual Studio 2015 are no longer correct (vcruntime140.dll and 2 others). Virustotal said they are for ARM architecture :-/ So its good to have a quick check whether it works as I described above. I could solve the problem by uninstalling the Redistributable and installing it again ( repairing didn't work ). Dependency Walker is a good research tool. Just to have a clue whats going on: after typing "import mapnik" in python the following happens:
Loaded "_MAPNIK.PYD" at address 0x66790000. Loaded "ICUUC56.DLL" at address 0x4A800000. Loaded "ICUDT56.DLL" at address 0x4AD00000. Loaded "VCRUNTIME140.DLL" at address 0x6D020000. Loaded "API-MS-WIN-CRT-RUNTIME-L1-1-0.DLL" at address 0x6CF60000. Loaded "UCRTBASE.DLL" at address 0x6A9F0000. Loaded "API-MS-WIN-CORE-TIMEZONE-L1-1-0.DLL" at address 0x6CF50000. Loaded "API-MS-WIN-CORE-FILE-L2-1-0.DLL" at address 0x6CF40000. Loaded "API-MS-WIN-CORE-LOCALIZATION-L1-2-0.DLL" at address 0x6CE40000. Loaded "API-MS-WIN-CORE-SYNCH-L1-2-0.DLL" at address 0x6FB80000. Loaded "API-MS-WIN-CORE-PROCESSTHREADS-L1-1-1.DLL" at address 0x6CE30000. Loaded "API-MS-WIN-CORE-FILE-L1-2-0.DLL" at address 0x6CE20000. Loaded "API-MS-WIN-CRT-STRING-L1-1-0.DLL" at address 0x6CE10000. Loaded "API-MS-WIN-CRT-HEAP-L1-1-0.DLL" at address 0x6CE00000. Loaded "API-MS-WIN-CRT-STDIO-L1-1-0.DLL" at address 0x6CDF0000. Loaded "API-MS-WIN-CRT-CONVERT-L1-1-0.DLL" at address 0x6CDE0000. Loaded "API-MS-WIN-CRT-ENVIRONMENT-L1-1-0.DLL" at address 0x6CDD0000. Loaded "API-MS-WIN-CRT-MATH-L1-1-0.DLL" at address 0x6CDC0000. Loaded "API-MS-WIN-CRT-TIME-L1-1-0.DLL" at address 0x6CDB0000. Loaded "BOOST_PYTHON-VC140-MT-1_59.DLL" at address 0x6CD10000. Loaded "MSVCP140.DLL" at address 0x6A850000. Loaded "API-MS-WIN-CRT-LOCALE-L1-1-0.DLL" at address 0x6CDA0000. Loaded "API-MS-WIN-CRT-MULTIBYTE-L1-1-0.DLL" at address 0x6CD90000. Loaded "API-MS-WIN-CRT-FILESYSTEM-L1-1-0.DLL" at address 0x6CD80000. Loaded "API-MS-WIN-CRT-UTILITY-L1-1-0.DLL" at address 0x6CD70000. Loaded "MAPNIK.DLL" at address 0x65AA0000. Loaded "LIBWEBP.DLL" at address 0x6A7F0000. Loaded "ICUIN56.DLL" at address 0x023C0000. Loaded "LIBPNG16.DLL" at address 0x6A7B0000. Loaded "LIBTIFF.DLL" at address 0x6A720000. Loaded "JPEG62.DLL" at address 0x6A6C0000. Loaded "CAIRO.DLL" at address 0x6A150000. Loaded "_HASHLIB.PYD" at address 0x6A050000. Loaded "CRYPTSP.DLL" at address 0x73620000. Loaded "RSAENH.DLL" at address 0x735E0000. Loaded "CSV.INPUT" at address 0x69C20000. Loaded "GDAL.INPUT" at address 0x6A680000. Loaded "GDAL200.DLL" at address 0x64AE0000. Loaded "LIBEXPAT.DLL" at address 0x69BB0000. Loaded "ODBC32.DLL" at address 0x701F0000. Loaded "WS2_32.DLL" at address 0x774B0000. Loaded "NSI.DLL" at address 0x76240000. Loaded "ODBCINT.DLL" at address 0x70D50000. Loaded "GEOJSON.INPUT" at address 0x69AF0000. Loaded "OGR.INPUT" at address 0x6A630000. Loaded "PGRASTER.INPUT" at address 0x69A90000. Loaded "WSOCK32.DLL" at address 0x6DC00000. Loaded "SHFOLDER.DLL" at address 0x6E210000. Loaded "SECUR32.DLL" at address 0x72C50000. Loaded "POSTGIS.INPUT" at address 0x68CA0000. Loaded "RASTER.INPUT" at address 0x6CCE0000. Loaded "SHAPE.INPUT" at address 0x69A50000. Loaded "SQLITE.INPUT" at address 0x649E0000. Loaded "TOPOJSON.INPUT" at address 0x68C10000.