opendp / smartnoise-sdk

Tools and service for differentially private processing of tabular and relational data
MIT License
254 stars 68 forks source link

Failed to import snsql #608

Open WCY-dt opened 3 weeks ago

WCY-dt commented 3 weeks ago

I followed the instruction to use pip to install the package. But I failed to import the package:

>>> import snsql
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:\Python312\Lib\site-packages\snsql\__init__.py", line 1, in <module>
    from .connect import from_connection, from_df
  File "E:\Python312\Lib\site-packages\snsql\connect.py", line 1, in <module>
    from .sql.private_reader import PrivateReader
  File "E:\Python312\Lib\site-packages\snsql\sql\__init__.py", line 1, in <module>
    from .private_reader import PrivateReader
  File "E:\Python312\Lib\site-packages\snsql\sql\private_reader.py", line 6, in <module>
    from snsql.sql.odometer import OdometerHeterogeneous
  File "E:\Python312\Lib\site-packages\snsql\sql\odometer.py", line 2, in <module>
    from snsql.sql.privacy import Privacy
  File "E:\Python312\Lib\site-packages\snsql\sql\privacy.py", line 2, in <module>
    from ._mechanisms import *
  File "E:\Python312\Lib\site-packages\snsql\sql\_mechanisms\__init__.py", line 1, in <module>
    from .laplace import Laplace
  File "E:\Python312\Lib\site-packages\snsql\sql\_mechanisms\laplace.py", line 3, in <module>
    from opendp.transformations import make_sum, make_clamp
  File "E:\Python312\Lib\site-packages\opendp\__init__.py", line 1, in <module>
    from opendp.mod import Transformation, Measurement, OpenDPException, UnknownTypeException
  File "E:\Python312\Lib\site-packages\opendp\mod.py", line 13, in <module>
    from opendp._lib import AnyMeasurement, AnyTransformation, AnyDomain, AnyMetric, AnyMeasure, AnyFunction
  File "E:\Python312\Lib\site-packages\opendp\_lib.py", line 46, in <module>
    lib, lib_path = _load_library()
                    ^^^^^^^^^^^^^^^
  File "E:\Python312\Lib\site-packages\opendp\_lib.py", line 31, in _load_library
    raise Exception(f"Expected exactly one binary to be present. Got: {lib_dir_file_names}")
Exception: Expected exactly one binary to be present. Got: []

I have tried in both Python3.12 and Python3.9, but none of them succeed.

WCY-dt commented 3 weeks ago

After I updated OpenDP to v0.11.1, the problem is solved.

MinzhiYoyo commented 3 weeks ago

I choose another way to solve this problem. Change PYTHON_HOME/Lib/site-packages/opendp/_lib.py line 29 to lib_dir_file_names = [p for p in lib_dir.iterdir() if p.suffix in {".so", ".dylib", ".dll", ".pyd"}]. Because there may be a bug in this version of OpenDP. I can find .so, .dylib, .dll in PYTHON_HOME\Lib\site-packages\opendp\lib, just find a .pyd.