wbolster / plyvel

Plyvel, a fast and feature-rich Python interface to LevelDB
https://plyvel.readthedocs.io/
Other
530 stars 75 forks source link

Symbol not found: __ZN7leveldb2DB4OpenERKNS_7OptionsERKSsPPS0_ on Mavericks #27

Closed varikin closed 10 years ago

varikin commented 10 years ago

Trying to get Plyvel working on Mavericks. I have LevelDB 1.15 installed via homebrew. In a Python 3.3 virtualenv, after pip install plyvel, I get the following:

Python 3.3.3 (default, Dec  4 2013, 09:48:34)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import plyvel
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "./plyvel/__init__.py", line 6, in <module>
    from ._plyvel import (  # noqa
ImportError: dlopen(./plyvel/_plyvel.so, 2): Symbol not found:   __ZN7leveldb2DB4OpenERKNS_7OptionsERKSsPPS0_
  Referenced from: ./plyvel/_plyvel.so
  Expected in: flat namespace
 in ./plyvel/_plyvel.so 

The docs say to ensure the linker can find the shared library, but I am not sure how to do that with pip. When grepping for that symbol, I find something similar, but not exact. Is this a version mismatch or I am just not looking at the right things?

nm /usr/local/lib/libleveldb.1.dylib | grep __ZN7leveldb2DB4Open
0000000000009456 T __ZN7leveldb2DB4OpenERKNS_7OptionsERKNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEPPS0_
wbolster commented 10 years ago

Are you sure the leveldb libs are in the LD_LIBRARY_PATH?

wbolster commented 10 years ago

Do you have multiple LevelDB versions installed? Maybe this is a mismatch between compile time and runtime versions.

varikin commented 10 years ago

LD_LIBRARY_PATH wasn't set so I set it and it didn't make a difference. I then uninstalled LevelDB and Plylel and then reinstalled them with LD_LIBRARY_PATH set to see if it had any affect. It didn't. Here is the current setting of LD_LIBRARY_PATH.

$ ls /usr/local/lib/libleveldb.*
/usr/local/lib/libleveldb.1.15.dylib /usr/local/lib/libleveldb.1.dylib    /usr/local/lib/libleveldb.a          /usr/local/lib/libleveldb.dylib
$ echo $LD_LIBRARY_PATH
/usr/local/lib
wbolster commented 10 years ago

I don't have much experience debugging issues like these. Did you compile LevelDB yourself using the same compiler?

varikin commented 10 years ago

I switched to working in Ubuntu Saucy and everything works. Not sure why my Mac environment is messed up, but considering I will be ultimately running this app from a Ubuntu, I am fine with this.

mchaput commented 10 years ago

I don't think this issue should have been closed, since it's still broken on Mavericks. I still have this problem. Installed leveldb with brew, installed plyvel pip, and get the same missing symbol.

ImportError: dlopen(/Users/matt/Dropbox/workspace/env/py33whoosh/lib/python3.3/site-packages/plyvel/_plyvel.so, 2): Symbol not found: __ZN7leveldb2DB4OpenERKNS_7OptionsERKSsPPS0_
  Referenced from: /Users/matt/Dropbox/workspace/env/py33whoosh/lib/python3.3/site-packages/plyvel/_plyvel.so
  Expected in: flat namespace
 in /Users/matt/Dropbox/workspace/env/py33whoosh/lib/python3.3/site-packages/plyvel/_plyvel.so
wbolster commented 10 years ago

Reopening. Please help debugging this, I'm not sure what the problem is.

mchaput commented 10 years ago

I'll do what I can :)

wbolster commented 10 years ago

So, is this with multiple LevelDB installations? Is LevelDB installed and reachable by the loader (LD_LIBRARY_PATH maybe)?

wbolster commented 10 years ago

Not familiar with this problem, but this looks similar to some extent: http://stackoverflow.com/questions/19737207/openssl-and-m2crypto-not-working-together-on-os-x-mavericks

wbolster commented 10 years ago

And maybe this one as well: http://stackoverflow.com/questions/21867277/installing-pillow-with-mac-os-x-mavericks-10-9-1

mchaput commented 10 years ago

I removed all python.org Pythons from my system and reinstalled using Homebrew's pythons, and now this works. It may have been a conflict between Homebrew's Leveldb and python.org Python.

wbolster commented 10 years ago

Great, glad to hear that it works for you now. I'll close this issue, since it does not seem to caused by Plyvel after all.

pinkplus commented 8 years ago

I encountered the same problem. It looks to me that the problem is caused by different C++ standard libraries used by leveldb and plyvel.

When I install leveldb (in the standard way, make), it is linked to libc++, which is the default standard library on OS X. However, when I install plyvel, it is linked to libstdc++ for some unknown reason. The name mangling is different for two libraries.

This command worked for me:

CFLAGS='-mmacosx-version-min=10.7 -stdlib=libc++' pip install plyvel
orsharir commented 8 years ago

I've encountered this issue as well, and so far can't find a solution. If plyvel relies on LD_LIBRARY_PATH, then you should know that on OS X El Capitan you can no longer use that due to possible security restrictions by the OS. I've seen this in other open-source projects that relies on this flag for loading libraries (e.g. see https://github.com/BVLC/caffe/issues/3227).

wbolster commented 8 years ago

i cannot reproduce this.

on osx el capitan with homebrew I can build/run plyvel just fine on different python versions after i brew install leveldb. the test suite passes; relevant snippets from the tox output:

  py26: commands succeeded
  py27: commands succeeded
  py33: commands succeeded
  py34: commands succeeded
mitallast commented 8 years ago

I have same problem on os x 10.11.3 with this commands:

brew install leveldb
pip install plyvel

plyvel package installed with wheels, so I try reinstall plyvel without wheels:

pip uninstall plyvel
CFLAGS='-mmacosx-version-min=10.7 -stdlib=libc++' pip install --no-use-wheel plyvel

Maybe something wrong with wheel package?

wbolster commented 8 years ago

plyvel does not provide wheel packages; those are built locally on your system by pip i think, so yeah, removing them from your local cache may help.

flaviovdf commented 8 years ago

Had the same issue, got it working by doing:

pip uninstall plyvel
CFLAGS='-mmacosx-version-min=10.7 -stdlib=libc++' pip install plyvel --no-cache-dir

The --no-cache-dir was needed, if it is not provided, pip will re-use the previous compilation.

ysunf commented 7 years ago

@flaviovdf His answer works for me. 👍 I install leveldb with homebrew, and install plyvel with pip. when i test "$python -c 'import plyvel'", it comes up the same 'Symbol' error. So i uninstall plyvel and reinstall with : CFLAGS='-mmacosx-version-min=10.7 -stdlib=libc++' pip install plyvel --no-cache-dir

Ayppo commented 7 years ago

Same problem on linux. I want to use commands like "CFLAGS='-mmacosx-version-min=10.7 -stdlib=libc++' pip install plyvel --no-cache-dir", but all failed

wbolster commented 7 years ago

@troyoung this is about a mac osx specific issue. please open a new issue and provide all relevant information if your problem persists.

jakeywu commented 3 years ago

i have solved my problem by install leveldb@1.21 which default is @1.23

https://cloud.tencent.com/developer/article/1815745

kobiebotha commented 2 years ago

@jakeywu Unfortunately 1.21 does not work Apple Sillicon

ManuelSchneid3r commented 1 year ago

Has anybody found an easy solution to this? Still an issue under ventura 13.2 (m1), leveldb 1.23, plyvel 1.5

abhi-jha commented 6 months ago

Yeah, this doesn't work on MacOS Sonoma 14.2.1.

I have installed leveldb on a custom path using : https://github.com/wbolster/plyvel/blob/main/scripts/install-leveldb.sh

I have a new path where both lib/ and include/ folders are available. I included these paths when running make which successfully generates the .so object.

Now when I install the libray itself using pip install ., it installs successfully. But when I do import it into a file it tells me the following :

Traceback (most recent call last):
  File "/path/temp/plyvel/leveldb_stuff.py", line 1, in <module>
    import plyvel
  File "/path/temp/plyvel/plyvel/__init__.py", line 6, in <module>
    from ._plyvel import (  # noqa
ImportError: dlopen(/path/temp/plyvel/plyvel/_plyvel.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '__ZTIN7leveldb10ComparatorE'

I am not sure if the lib path needs to be provided again somewhere. I mostly edited the setup.py file.

NOTE that make succeeded successfully and there is an .so file in the folder.