Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
unicornlox opened this issue Apr 13, 2018 · 10 comments

Comments

@unicornlox
Copy link

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

@komackaj
Copy link
Collaborator

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.

@ThimoNeubauer
Copy link

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

@komackaj
Copy link
Collaborator

@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).

@JIAZHEN
Copy link

JIAZHEN commented Jun 27, 2018

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
Copy link

JIAZHEN commented Jun 27, 2018

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

@JIAZHEN
Copy link

JIAZHEN commented Jun 29, 2018

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

@JIAZHEN
Copy link

JIAZHEN commented Jun 30, 2018

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

@arycloud
Copy link

arycloud commented Sep 4, 2018

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

@MedhatAhmed
Copy link

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

how did you resolve the issue :)

@totalspam
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants