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 theimport libtestas 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
libtestmodule 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.soand script so they can easily be downloaded?
libtest.pyiin the same folder as your.soto have your IDE know that the functionality exists.PYTHONPATHenvironment variable to find modules, the path to the.soneeds to be on it, notPATH.