8000 cannot import pyhash from python35 · Issue #18 · flier/pyfasthash · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cannot import pyhash from python35 #18

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

Closed
hvnsweeting opened this issue Oct 1, 2017 · 7 comments
Closed

cannot import pyhash from python35 #18

hvnsweeting opened this issue Oct 1, 2017 · 7 comments

Comments

@hvnsweeting
Copy link
python
Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyhash
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hvn/py35env/lib/python3.5/site-packages/pyhash.py", line 7, in <module>
    import _pyhash
ImportError: /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.58.0: undefined symbol: PyClass_Type
$ pip freeze | grep -i pyhash
pyhash==0.8.1

$ dpkg -l 'libboost-all-*' | grep ^ii
ii  libboost-all-dev 1.58.0.1ubuntu1 amd64        Boost C++ Libraries development files (ALL) (default version)

$ ls /usr/lib/x86_64-linux-gnu/libboost_python*/usr/lib/x86_64-linux-gnu/libboost_python.a
/usr/lib/x86_64-linux-gnu/libboost_python-py27.a
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.58.0
/usr/lib/x86_64-linux-gnu/libboost_python-py35.a
/usr/lib/x86_64-linux-gnu/libboost_python-py35.so
/usr/lib/x86_64-linux-gnu/libboost_python-py35.so.1.58.0
/usr/lib/x86_64-linux-gnu/libboost_python.so


$ lsb_release -d
Description:	Ubuntu 16.04.2 LTS

Though, it works okay on python 2 virtualenv

@flier
Copy link
Owner
flier commented Oct 5, 2017

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

You install and link pyfasthash with libboost_python which linked to Python 2.7

@hvnsweeting
Copy link
Author

I changed the dest of symlink /usr/lib/x86_64-linux-gnu/libboost_python.{so,a} to py35 files and re-install, it works now.

So by default, pip install pyhash will use the version that libboost_python.so symlink currently points to.
On my machine, I have both python35 and python27, and I want to use pyhash in both of these version.
Is there a better way to make pip/setup.py choice the correct version?
I see code in setup.py does something alike on TRAVIS, but that might break normal machine

if os.getenv('TRAVIS') == 'true':
    print("force to link boost::python base on Python v%d.%d" % (sys.version_info.major, sys.version_info.minor))

    os.remove('/usr/lib/libboost_python.so')
    os.symlink('/usr/lib/libboost_python-py%d%d.so' % (sys.version_info.major, sys.version_info.minor),
'/usr/lib/libboost_python.so')

@flier
Copy link
Owner
flier commented Oct 12, 2017

I'm committed a patch for this, auto detect Python version for boost::python, you may try it, then I will merge it to master branch.

@hvnsweeting
Copy link
Author

I tried, it failed

x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5/src/Hash.o build/temp.linux-x86_64-3.5/src/fnv/hash_32.o build/temp.linux-x86_64-3.5/src/fnv/hash_32a.o build/temp.linux-x86_64-3.5/src/fnv/hash_64.o build/temp.linux-x86_64-3.5/src/fnv/hash_64a.o build/temp.linux-x86_64-3.5/src/SuperFastHash/SuperFastHash.o build/temp.linux-x86_64-3.5/src/smhasher/MurmurHash1.o build/temp.linux-x86_64-3.5/src/smhasher/MurmurHash2.o build/temp.linux-x86_64-3.5/src/smhasher/MurmurHash3.o build/temp.linux-x86_64-3.5/src/smhasher/City.o build/temp.linux-x86_64-3.5/src/smhasher/Spooky.o build/temp.linux-x86_64-3.5/src/smhasher/metrohash64.o build/temp.linux-x86_64-3.5/src/smhasher/metrohash64crc.o build/temp.linux-x86_64-3.5/src/smhasher/metrohash128.o build/temp.linux-x86_64-3.5/src/smhasher/metrohash128crc.o build/temp.linux-x86_64-3.5/src/smhasher/t1ha.o build/temp.linux-x86_64-3.5/src/smhasher/xxhash.o build/temp.linux-x86_64-3.5/src/smhasher/farmhash-c.o build/temp.linux-x86_64-3.5/src/lookup3/lookup3.o -lboost_python-py35.so -lrt -lgcc -o build/lib.linux-x86_64-3.5/_pyhash.cpython-35m-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -lboost_python-py35.so
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-g++' failed with exit status 1
Command exited with non-zero status 1

I remove .so, it worked

x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5/src/Hash.o build/temp.linux-x86_64-3.5/src/fnv/hash_32.o build/temp.linux-x86_64-3.5/src/fnv/hash_32a.o build/temp.linux-x86_64-3.5/src/fnv/hash_64.o build/temp.linux-x86_64-3.5/src/fnv/hash_64a.o build/temp.linux-x86_64-3.5/src/lookup3/lookup3.o build/temp.linux-x86_64-3.5/src/smhasher/MurmurHash1.o build/temp.linux-x86_64-3.5/src/smhasher/MurmurHash2.o build/temp.linux-x86_64-3.5/src/smhasher/MurmurHash3.o build/temp.linux-x86_64-3.5/src/smhasher/City.o build/temp.linux-x86_64-3.5/src/smhasher/Spooky.o build/temp.linux-x86_64-3.5/src/smhasher/metrohash64.o build/temp.linux-x86_64-3.5/src/smhasher/metrohash64crc.o build/temp.linux-x86_64-3.5/src/smhasher/metrohash128.o build/temp.linux-x86_64-3.5/src/smhasher/metrohash128crc.o build/temp.linux-x86_64-3.5/src/smhasher/t1ha.o build/temp.linux-x86_64-3.5/src/smhasher/xxhash.o build/temp.linux-x86_64-3.5/src/smhasher/farmhash-c.o build/temp.linux-x86_64-3.5/src/SuperFastHash/SuperFastHash.o -lboost_python-py35 -lrt -lgcc -o build/lib.linux-x86_64-3.5/_pyhash.cpython-35m-x86_64-linux-gnu.so
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-3.5/_pyhash.cpython-35m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-3.5/pyhash.py -> build/bdist.linux-x86_64/egg
byte-compiling build/bdist.linux-x86_64/egg/pyhash.py to pyhash.cpython-35.pyc
creating stub loader for _pyhash.cpython-35m-x86_64-linux-gnu.so
byte-compiling build/bdist.linux-x86_64/egg/_pyhash.py to _pyhash.cpython-35.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying pyhash.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyhash.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyhash.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying pyhash.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
__pycache__._pyhash.cpython-35: module references __file__
creating 'dist/pyhash-0.8.1-py3.5-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing pyhash-0.8.1-py3.5-linux-x86_64.egg
creating /home/hvn/py35env/lib/python3.5/site-packages/pyhash-0.8.1-py3.5-linux-x86_64.egg
Extracting pyhash-0.8.1-py3.5-linux-x86_64.egg to /home/hvn/py35env/lib/python3.5/site-packages
Adding pyhash 0.8.1 to easy-install.pth file

Installed /home/hvn/py35env/lib/python3.5/site-packages/pyhash-0.8.1-py3.5-linux-x86_64.egg
Processing dependencies for pyhash==0.8.1
Finished processing dependencies for pyhash==0.8.1
$ python -c 'import pyhash, sys; print(sys.version)'
3.5.2 (default, Nov 17 2016, 17:05:23) 
[GCC 5.4.0 20160609]

I created PR #19

@flier
Copy link
Owner
flier commented Oct 12, 2017

@hvnsweeting
Copy link
Author

Thanks, it works.

@flier
Copy link
Owner
flier commented Oct 16, 2017

pyhash 0.8.2

@flier flier closed this as completed Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0