Do I need to set LD_LIBRARY_PATH for .so libraries?

I received a preview version of a Python module from another team. The module is implemented in C++ (I guess). They do not provide a pip installable module at this time, nor do they have documentation. Therefore they just send me some .pyi files and a .so library.

I did some research on how to install this .so file in my environment. I found some articles that mention setting the LD_LIBRARY_PATH environment variable. For example this one.

Set LD_LIBRARY_PATH before importing in python

However, this article is very old and it didn’t work for me. My question is, is it really necessary to set LD_LIBRARY_PATH ?

I work on Ubuntu 22.04 with Python 3.10. Thanks in advance.

1 Like

Just add the .so on your PYTHONPATH and it should import.


Thanks for your answer. Yes, this works.

Unfortunately, I cannot mark your answer as answer to my question. I’m sorry.