openfheorg / openfhe-python

Official Python wrapper for OpenFHE. Current release is v0.8.9 (released on September 10, 2024).
https://openfheorg.github.io/openfhe-python/html/index.html
BSD 2-Clause "Simplified" License
73 stars 21 forks source link

Python cannot find .so after using pip install #138

Closed sei-adolgert closed 4 months ago

sei-adolgert commented 4 months ago

To recreate this problem:

  1. Checkout openfhe-python source code and its dependencies.
  2. Make a new virtual environment in another directory.
  3. pip install directory-of/openfhe-python
  4. python -c "import('openfhe')"

Cause of the problem:

The openfhe-python library uses an init.py file that has a local import statement. When you run that local import from a different location on disk, it looks in a place relative to that different location, so it doesn't find the .so.

The relative import that is currently there:

from .openfhe import *

Suggested fix:

Use an absolute import statement, so that it is relative to the base of the library, not the current directory.

from openfhe.openfhe import *