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

Symbol not found: __ZN7leveldb2DB4OpenERKNS_7OptionsERKSsPPS0_ on Mavericks #27

Closed
varikin opened this issue Feb 11, 2014 · 26 comments
Closed

Comments

@varikin
Copy link

varikin commented Feb 11, 2014

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

Are you sure the leveldb libs are in the LD_LIBRARY_PATH?

@wbolster
Copy link
Owner

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

@varikin
Copy link
Author

varikin commented Feb 12, 2014

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

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

@varikin
Copy link
Author

varikin commented Feb 13, 2014

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.

@varikin varikin closed this as completed Feb 13, 2014
@mchaput
Copy link

mchaput commented Feb 25, 2014

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 wbolster reopened this Feb 25, 2014
@wbolster
Copy link
Owner

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

@mchaput
Copy link

mchaput commented Feb 26, 2014

I'll do what I can :)

@wbolster
Copy link
Owner

wbolster commented Mar 4, 2014

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

@wbolster
Copy link
Owner

wbolster commented Mar 4, 2014

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

wbolster commented Mar 4, 2014

@mchaput
Copy link

mchaput commented Mar 10, 2014

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

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

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

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 BVLC/caffe#3227).

@wbolster
Copy link
Owner

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

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

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

flaviovdf commented Aug 2, 2016

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

ysunf commented Nov 30, 2016

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

Ayppo commented Feb 16, 2017

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

wbolster commented Feb 16, 2017

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

@jakeywu
Copy link

jakeywu commented Jul 28, 2021

i have solved my problem by install [email protected] which default is @1.23

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

@kobiebotha
Copy link

@jakeywu Unfortunately 1.21 does not work Apple Sillicon

@ManuelSchneid3r
Copy link

ManuelSchneid3r commented Feb 16, 2023

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

@abhi-jha
Copy link

abhi-jha commented Feb 27, 2024

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.

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