Импорт общего объекта в Python с помощью pybind11Python

Программы на Python
Гость
Импорт общего объекта в Python с помощью pybind11

Сообщение Гость »


I'm trying to call my .so file from a python script. I've used pybind11 a to build the .so with a "hello" function that I want to call from my Python code. Apparently for it to be imported it needs to have a certain name like this: "libtest.cpython-311-x86_64-linux-gnu.so". With this I can import it as "libtest" and then call my hello function (which is inside the shared object). But there are two problems:
  • My IDE (CLion) does not seem to understand what is being imported at all and highlights the import libtest as an error, even though I can execute it normally. (This is probably not a question for SO, but if someone knows please let me know as well)
  • I can only import the libtest module if the .so is in the same folder as my python script. Is there a way to import it independently of the path, for example, can I import it from /usr/bin? I have tried adding it to $PATH but this didn't seem to do anything. So how is it possible to "bundle" the .so and script so they can easily be downloaded?


Источник: https://stackoverflow.com/questions/780 ... g-pybind11

Вернуться в «Python»