pgmagick icon indicating copy to clipboard operation
pgmagick copied to clipboard

ImportError: /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.58.0: undefined symbol: PyClass_Type

Open unicornlox opened this issue 6 years ago • 10 comments

When I import the PGMagick module I get this error:(from pgmagick import gminfo)(python3.6, ubuntu 16.04)thank you very much for your help.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/pgmagick/__init__.py", line 1, in <module>
    from pgmagick import _pgmagick
ImportError: /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.58.0: undefined symbol: PyClass_Type

unicornlox avatar Apr 13 '18 00:04 unicornlox

Hi,

thank you for the report. Looks like the compiled module has bad linkage.

Have you installed it from PyPi (using pip) or compiled from source? Could you post pip's output / your compilation procedure? Do you use some special PPA repositories for python - according to this Python 3.5 is default in Xenial.

komackaj avatar Apr 13 '18 07:04 komackaj

I've got apparently the same issue on MacOS:

>>> import pgmagick
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/pgmagick-0.6.5-py3.6-macosx-10.13-x86_64.egg/pgmagick/__init__.py", line 1, in <module>
    from pgmagick import _pgmagick
ImportError: dlopen(/usr/local/lib/python3.6/site-packages/pgmagick-0.6.5-py3.6-macosx-10.13-x86_64.egg/pgmagick/_pgmagick.cpython-36m-darwin.so, 2): Symbol not found: _PyClass_Type
  Referenced from: /usr/local/opt/boost-python/lib/libboost_python-mt.dylib
  Expected in: flat namespace
 in /usr/local/opt/boost-python/lib/libboost_python-mt.dylib

I'm pasting the installation log below. Note that Boost Python was installed right before pgmagick was built: the linkage should be consistent that way. What I suspect is that Boost Python was built against Python 2.7? The Ubunto error above also looks like a Python version mismatch

Flunder:~ thimo$ brew tap hhatto/pgmagick
==> Tapping hhatto/pgmagick
Cloning into '/usr/local/Homebrew/Library/Taps/hhatto/homebrew-pgmagick'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 0), reused 2 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
Tapped 1 formula (31 files, 23.7KB)
Flunder:~ thimo$ brew install pgmagick --with-python3
==> Installing pgmagick from hhatto/pgmagick
==> Installing dependencies for hhatto/pgmagick/pgmagick: sqlite, boost-python
==> Installing hhatto/pgmagick/pgmagick dependency: sqlite
==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.23.1.high_sierra.b
==> Downloading from https://akamai.bintray.com/0b/0b5f0e6d1096fbed10367e53c13c0
######################################################################## 100.0%
==> Pouring sqlite-3.23.1.high_sierra.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS provides an older sqlite3.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/sqlite/lib
    CPPFLAGS: -I/usr/local/opt/sqlite/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/sqlite/lib/pkgconfig

==> Summary
🍺  /usr/local/Cellar/sqlite/3.23.1: 11 files, 3MB
==> Installing hhatto/pgmagick/pgmagick dependency: boost-python
==> Downloading https://homebrew.bintray.com/bottles/boost-python-1.66.0_1.high_
==> Downloading from https://akamai.bintray.com/90/908a5484b565b1ee55ccec7d1f3e1
######################################################################## 100.0%
==> Pouring boost-python-1.66.0_1.high_sierra.bottle.tar.gz
🍺  /usr/local/Cellar/boost-python/1.66.0_1: 457 files, 17.3MB
==> Installing hhatto/pgmagick/pgmagick --with-python3
==> Downloading https://github.com/hhatto/pgmagick/archive/ver0.6.5.tar.gz
==> Downloading from https://codeload.github.com/hhatto/pgmagick/tar.gz/ver0.6.5
######################################################################## 100.0%
==> python3 setup.py install --prefix=/usr/local/Cellar/pgmagick/0.6.5
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink lib/python3.6/site-packages/easy-install.pth
Target /usr/local/lib/python3.6/site-packages/easy-install.pth
already exists. You may want to remove it:
  rm '/usr/local/lib/python3.6/site-packages/easy-install.pth'

To force the link and overwrite all conflicting files:
  brew link --overwrite pgmagick

To list all files that would be deleted:
  brew link --overwrite --dry-run pgmagick

Possible conflicting files are:
/usr/local/lib/python3.6/site-packages/easy-install.pth
==> Summary
🍺  /usr/local/Cellar/pgmagick/0.6.5: 23 files, 5.8MB, built in 7 minutes 6 seconds
Flunder:~ thimo$ rm '/usr/local/lib/python3.6/site-packages/easy-install.pth'
Flunder:~ thimo$ brew link --overwrite pgmagick
Linking /usr/local/Cellar/pgmagick/0.6.5... 13 symlinks created

ThimoNeubauer avatar Apr 14 '18 07:04 ThimoNeubauer

@ThimoNeubauer Thank you for reporting. Linking with Boost Python for python3 is always a tricky one. I currently have no access to MacOS machine, so I cannot reproduce, moreover the build pipeline for Homebrew is different from the Linux one.

@hhatto Could you look into this and maybe create a separate issue for Homebrew? Maybe is fixed for current version (I can see from the logs 0.6.5 is built).

komackaj avatar Apr 15 '18 08:04 komackaj

I have a similar issue,

>>> import pgmagick as pg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/www/application/deploy/shared/site-packages/pgmagick/__init__.py", line 1, in <module>
    from pgmagick import _pgmagick
ImportError: /usr/lib64/libboost_python-mt.so.1.53.0: undefined symbol: PyClass_Type

It must be something to do with the python3 and boost-python ..

JIAZHEN avatar Jun 27 '18 16:06 JIAZHEN

@hhatto & @komackaj could you please have a look?

JIAZHEN avatar Jun 27 '18 16:06 JIAZHEN

In my case, the linux is AWS ami which is redhat. The boost-devel package doesn't include libboost-python3x.

JIAZHEN avatar Jun 29 '18 11:06 JIAZHEN

I solved it ... Nightmare to install it on aws ami.

JIAZHEN avatar Jun 30 '18 22:06 JIAZHEN

I have the similar issue on Mac OS Mojave with Python 3 using pip install pgmagick using Pycharm: <module> from pgmagick import _pgmagick ImportError: dlopen(/Users/abdul/ImgSegEnv/lib/python3.6/site-packages/pgmagick/_pgmagick.cpython-36m-darwin.so, 2): Library not loaded: /usr/local/opt/boost-python3/lib/libboost_python36.dylib Referenced from: /Users/abdul/ImgSegEnv/lib/python3.6/site-packages/pgmagick/_pgmagick.cpython-36m-darwin.so Reason: image not found

arycloud avatar Sep 04 '18 04:09 arycloud

I solved it ... Nightmare to install it on aws ami.

how did you resolve the issue :)

MedhatAhmed avatar May 15 '20 14:05 MedhatAhmed

I have the same issue after success install boost, harfbuzz and mapnik libraries from source with make install (Ubuntu 18.04): python3 -c "import mapnik;print(mapnik.__file__)" Traceback (most recent call last): File "<string>", line 1, in <module> File "/root/src/python-mapnik/mapnik/__init__.py", line 74, in <module> from ._mapnik import * ImportError: /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.65.1: undefined symbol: PyClass_Type

totalspam avatar Jul 20 '21 08:07 totalspam