I would recommend getting the path(s) that cannot be found from Python. It seems you’re on Windows; I think Python 3.10 or 3.11 got better error messages. If that’s not possible, ProcMon can be used to sniff error states; you’ll need to set up some filters to make it useful.
I tried to reproduce your problem, and got the same result, and it happens no matter where I put the DLLs (leveldb.dll and snappy.dll), even if their location is definitely part of the PATH.
And as it turns out, starting with Python 3.8(?) there is now a more strict check for DLL loading paths, so one has to explicitly “allow” paths of interest with os.add_dll_directory(), and that seems to make it work:
Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32
>>> import plyvel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "e:\temp\some\plyvel\plyvel\__init__.py", line 6, in <module>
from ._plyvel import ( # noqa
ImportError: DLL load failed while importing _plyvel: The specified module could not be found.
>>> import os
>>> os.add_dll_directory("e:/temp/some/plyvel")
<AddedDllDirectory('e:/temp/some/plyvel')>
>>> import plyvel
>>> db = plyvel.DB('e:/temp/testdb/', create_if_missing=True)
>>> os.listdir("e:/temp/testdb/")
['000003.log', 'CURRENT', 'LOCK', 'LOG', 'MANIFEST-000002']
Can’t see on your screenshot if libraries are in fact inside the path you are adding. But if it’s the same path, then it is weird indeed. Is the error absolutely the same as before?
Also, looking at your DLLs sizes, mine are different:
$ du -hs ./*.dll
260K ./leveldb.dll
212K ./snappy.dll
I’ve built Release configuration for both, and it was the latest commits from both their repositories. If you have used the same revisions and configuration, then it is strange that your leveldb.dll is more than 3 times bigger than mine.
I would also check that leveldb build actually did link to snappy, because it doesn’t fail it it is not found, just builds without it.
We can use personal messages here on the forum, I prefer not mix my identities
Also, this discussion might be of interest for others, so it’s worth keeping it public, at least until moderators would ask us to stop spamming.
I didn’t use those scripts, here are my steps:
$ cd /e/temp
$ mkdir some && cd $_
$ git clone --depth 1 git@github.com:google/snappy.git
$ git clone --depth 1 git@github.com:google/leveldb.git
$ git clone --depth 1 git@github.com:wbolster/plyvel.git
$ cd ./snappy
$ git rev-parse HEAD
27f34a580be4a3becf5f8c0cba13433f53c21337
$ mkdir build && cd build
$ cmake -G Ninja -DBUILD_SHARED_LIBS=1 -DCMAKE_POSITION_INDEPENDENT_CODE=1 -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=1 -DCMAKE_INSTALL_PREFIX="../install" -DSNAPPY_BUILD_TES
TS=0 -DSNAPPY_BUILD_BENCHMARKS=0 ..
$ cmake --build . --target install
$ cd ../../leveldb
$ git rev-parse HEAD
068d5ee1a3ac40dabd00d211d5013af44be55bea
$ mkdir build && cd build
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DCMAKE_POSITION_INDEPENDENT_CODE=1 -DLEVELDB_BUILD_TESTS=0 -DLEVELDB_BUILD_BENCHMARKS=0 -DCMAKE_INS
TALL_PREFIX="../install" -DCMAKE_PREFIX_PATH="e:/temp/some/snappy/install" ..
$ cmake --build . --target install
$ cd ../../plyvel
$ git rev-parse HEAD
fc99b8ebdd1e93ff53138c98bc3f90d786158cad
$ make
$ python setup.py bdist_wheel
$ du -hs ./dist/plyvel-1.5.0-cp311-cp311-win_amd64.whl
100K
$ pip install ./dist/plyvel-1.5.0-cp311-cp311-win_amd64.whl
…forgot to mention, in case it isn’t obvious, the path added with os.add_dll_directory() still needs to be discoverable (be part of the PATH), as this function seems to only “allow” loading from there, I don’t think it actually loads anything. And the path on your screenshot doesn’t look like it is part of the PATH (unless you actually added it to PATH).
In my case I was launching Python from the same working folder where the DLLs are, so they were discoverable.
– Building for: Visual Studio 17 2022
– Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19045.
– The C compiler identification is MSVC 19.33.31630.0
– The CXX compiler identification is MSVC 19.33.31630.0