mapnik / python-mapnik

Python bindings for mapnik
GNU Lesser General Public License v2.1
160 stars 91 forks source link

ImportError: mapnik/_mapnik.so: undefined symbol: _ZTIN6icu_5713UnicodeStringE #161

Open borisq opened 7 years ago

borisq commented 7 years ago

Hi! I just installed the python-mapnik bindings and everything went fine until I tried to import it into python:

>>> import mapnik
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mapnik/__init__.py", line 74, in <module>
    from ._mapnik import *
ImportError: mapnik/_mapnik.so: undefined symbol: _ZTIN6icu_5713UnicodeStringE

I saw several approaching issues but none which was able to help solving this issue. I built both mapnik 3.1 and python-mapnik from source.

Thanks! Boris

bukun commented 6 years ago

I am testing codes for my new book. I have just installed Ubuntu 17.01 released several days ago. I also fond the error, both on Python 2.7 and Python 3.6.

Under Python 3.6:

➜  py3gis git:(master) python3
Python 3.6.3 (default, Oct  3 2017, 21:45:48) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/mapnik/__init__.py", line 74, in <module>
    from ._mapnik import *
ImportError: /usr/lib/python3/dist-packages/mapnik/_mapnik.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZTIN6mapnik15freetype_engineE
>>> exit()
*** Error in `python3': corrupted size vs. prev_size: 0x0000000000dfa080 ***
[2]    2018 abort (core dumped)  python3

Under Python 2.7:

➜  py3gis git:(master) python
Python 2.7.14 (default, Sep 23 2017, 22:06:14) 
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/mapnik/__init__.py", line 74, in <module>
    from ._mapnik import *
ImportError: /usr/lib/python2.7/dist-packages/mapnik/_mapnik.x86_64-linux-gnu.so: undefined symbol: _ZTIN6mapnik15freetype_engineE
>>> exit()
TeAmigo commented 6 years ago

I'm having the same issue mentioned above using Ubuntu 17.10 and the apt distributed packages. Here's the command and the result. $ python -c "import mapnik;print mapnik.file" Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/dist-packages/mapnik/init.py", line 74, in from ._mapnik import * ImportError: /usr/lib/python2.7/dist-packages/mapnik/_mapnik.x86_64-linux-gnu.so: undefined symbol: _ZTIN6mapnik15freetype_engineE

TeAmigo commented 6 years ago

Mapnik seems to be required by so many mapping tools, yet these problems seem to persist indefinitely. Are there other mapping solutions that don't rely on python-mapnik?

SomeoneElseOSM commented 6 years ago

I hit the same problem while trying to do an Ubuntu 17.10 version of OSM's "switch2osm"guide. That guide deliberately compiles as little as possible from source, so it'd be great to have working versions back in the next (LTS) version of Ubuntu, but presumably that depends on figuring out which versions are compatible first?

savelov commented 6 years ago

make sense to raise priority of ubuntu bug if all want to be fixed for 18.04 - - root cause is that mapnik and python-mapnik are of different versions https://bugs.launchpad.net/ubuntu/+source/python-mapnik/+bug/1734142

gorshkov-leonid commented 6 years ago

I hav got the same problem (_ZTIN6icu_5713UnicodeStringE). mapnik 3.0.16, python mapnik 3.0.16, boost 1.65.1 with icu4c 62.1(in system). Ubuntu 18.04 (WSL). All of them apart from icu have build from sources. I note that mapnik 3.0.16 found own version icu.

talaj commented 6 years ago

I note that mapnik 3.0.16 found own version icu.

What do you mean by that? If Mapnik is built against one ICU version and run against another, this is a kind of error one would expect to see.

gorshkov-leonid commented 6 years ago

I mean I make it according to installation instruction and got an error. So I tried to build mapnik 3.1 and then used python mapnik. I decided a dozen problems that related to ubuntu-18 and specificity of wsl, that related to a compatibility of different libraries.
But It is figured out that python-mapnik is not working with 3.1. But now I have some last versions of libraries that I needed to install for 3.1. So it could be considered I use fresh system with set of fresh libraries. Then I tried to build and use mapnik 3.0.20/python-mapnik 3.0.16 and 3.0.16/3.0.16. What I need to do to fix it? How to specify system version of icu for mapnik, I don't want build icu 57 (6x are destributed as binaries for ubuntu 64, but 57 - doesn't)

talaj commented 6 years ago

I've just installed Ubuntu 18 Bionic and tried to build Mapnik tag v3.0.20 with v3.0.x branch of python-mapnik. All went fine when I installed all required dependencies. No error during import mapnik.

There is also packaged version 3.0.19+ds-1 of Mapnik in Bionic, universe repository. Also seems to work fine.

talaj commented 6 years ago

For 3.0.x series of Mapnik on Ubuntu 18 Bionic, there is no need to build any dependency from source. All dependencies are packaged in the system.

This is not true for 3.1 version of Mapnik, which is development version and hasn't been released yet. I would not recommend to use it unless you want to participate on development.

gorshkov-leonid commented 6 years ago

@talaj Thank you for useful advice. I tried to reinstall mapnik and python-mapnik. But there was another error

gorshkov:usr$ find "$PWD"/ -name "*mapnik*"
/usr/bin/mapnik-config
/usr/bin/mapnik-plugin-base
/usr/include/mapnik
/usr/lib/libmapnik-json.a
/usr/lib/libmapnik-wkt.a
/usr/lib/libmapnik.so
/usr/lib/libmapnik.so.3.0
/usr/lib/libmapnik.so.3.0.19
/usr/lib/mapnik
/usr/lib/python2.7/dist-packages/mapnik
/usr/lib/python2.7/dist-packages/mapnik/_mapnik.x86_64-linux-gnu.so
/usr/lib/python2.7/dist-packages/mapnik/mapnik_settings.py
/usr/lib/python2.7/dist-packages/mapnik/mapnik_settings.pyc
/usr/lib/python2.7/dist-packages/mapnik-0.1.egg-info
/usr/share/doc/libmapnik-dev
/usr/share/doc/libmapnik3.0
/usr/share/doc/mapnik-doc
/usr/share/doc/mapnik-doc/examples/viewer/images/mapnik.png
/usr/share/doc/mapnik-doc/examples/viewer/mapnik_viewer.qrc
/usr/share/doc/python-mapnik
/usr/share/lintian/overrides/libmapnik3.0
/usr/share/man/man1/mapnik-config.1.gz
/usr/share/man/man1/mapnik-plugin-base.1.gz

gorshkov:usr$ readlink -f /usr/lib/libmapnik.so.3.0
/usr/lib/libmapnik.so.3.0.19

gorshkov:usr$ readlink -f /usr/lib/libmapnik.so
/usr/lib/libmapnik.so.3.0.19

gorshkov:usr$ /usr/bin/mapnik-config -v
3.0.19

gorshkov:3.0$ apt list --installed | grep mapnik
libmapnik-dev/bionic,now 3.0.19+ds-1 amd64 [installed]
libmapnik3.0/bionic,now 3.0.19+ds-1 amd64 [installed,automatic]
mapnik-doc/bionic,now 3.0.19+ds-1 all [installed,automatic]
python-mapnik/bionic,now 1:0.0~20180130-804a7947d-1 amd64 [installed]

gorshkov:3.0$ python -c "import mapnik;print mapnik.__file__"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/mapnik/__init__.py", line 74, in <module>
    from ._mapnik import *
ImportError: /usr/lib/libmapnik.so.3.0: undefined symbol: _ZNK5boost16re_detail_10650131icu_regex_traits_implementation12do_transformEPKiS3_PKN6icu_608CollatorE
gorshkov:local$ apt list --installed | grep icu
icu-devtools/bionic,now 60.2-3ubuntu3 amd64 [installed,automatic]
libharfbuzz-icu0/bionic,now 1.7.2-1ubuntu1 amd64 [installed,automatic]
libicu-dev/bionic,now 60.2-3ubuntu3 amd64 [installed,automatic]
libicu-le-hb-dev/bionic,now 1.0.3+git161113-4 amd64 [installed,automatic]
libicu-le-hb0/bionic,now 1.0.3+git161113-4 amd64 [installed,automatic]
libicu60/bionic,now 60.2-3ubuntu3 amd64 [installed]
libiculx60/bionic,now 60.2-3ubuntu3 amd64 [installed,automatic]

icu.txt

talaj commented 6 years ago

@gorshkov-leonid, according to the file listing you provided, you have two versions of ICU installed. One in /usr and another in /usr/local. I think also Boost is installed twice. That is not wrong generally, but one has to be careful.

I would say one of these commands should work:

LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/local/lib python -c "import mapnik;print mapnik.__file__"
LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/x86_64-linux-gnu python -c "import mapnik;print mapnik.__file__"

Anyways, if you don't need those libraries from /usr/local for other purposes, just move or remove /usr/local out and build/install Mapnik against clean system.

gorshkov-leonid commented 6 years ago

Thank you very much! It's working!!!! There was the problem with libboost_regex.so.1.65.1 (with icu support) that requires libicui18n.so.62. But it was downloaded automatically as dependency. I renamed it

soccerdroid commented 5 years ago

Thank you very much! It's working!!!! There was the problem with libboost_regex.so.1.65.1 (with icu support) that requires libicui18n.so.62. But it was downloaded automatically as dependency. I renamed it

Could you provide more information about your solution please? @gorshkov-leonid I have this same error : File "/usr/lib64/python3.6/site-packages/mapnik/__init__.py", line 74, in <module> from ._mapnik import * ImportError: /usr/local/lib/libmapnik.so.3.0: undefined symbol: _ZNSt13runtime_errorC1EPKc