Workaround if you cannot add to LD_LIBRARY_PATH

I want to add it as a shared library search path, but it is a workaround when I do not have permission.

Thing you want to do

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

I want to read the file contained in it.

Workaround

Assuming there is "/home/username/usr/lib/XXXX.so" in the python file

import ctypes
ctypes.cdll.LoadLibrary('/home/username/usr/lib/XXXX.so')

If you forcibly read it once, it will be reused even when it is loaded in the library, so it will work.

Example (if you want to read CaboCha)

import CaboCha

If you get angry because "libcabocha.so.5" is missing when you try to do

import ctypes
ctypes.cdll.LoadLibrary('/home/username/usr/lib/libcabocha.so.5')
import CaboCha

It works safely with.

Recommended Posts

Workaround if you cannot add to LD_LIBRARY_PATH
[Edge2Imori] Epi.2 pix What if you add Gradient Penalty to pix? ??
[* CentOS 6.10] What to do if you cannot add the IUS Community Project repository on CentOS 6.5 (VirtualBox)
Workaround if you get an error when trying to install PySide with pip
What to do if you can't pipenv shell
What to do if mod_fcgid cannot resolve UnicodeEncodeError
If you want to create a Word Cloud.
What to do if pip cannot be installed
What to do if you can't pip install mysqlclient
No module named What to do if you get'libs.resources'
ModuleNotFoundError: No module What to do if you get'tensorflow.contrib'
If you want to use Cython, also include python-dev
Add convolution to MNIST
If you want Linux to boot even if the disk mount fails, add the nofail option to fstab.
What to do if you get a Cannot retrieve metalink for repository error in yum
One liner to hit if you forget where today is
[Python] If you suddenly want to create an inquiry form
Why do you add a main ()-if statement in Python?
What to do if the package dependency cannot be repaired
What to do if you are addicted to Windows character code
What to do if you get "coverage unknown" in Coveralls
What to do if you can't sort files with subscripts
If it is not easy to understand, it cannot be improved.
What to do if you can't log in as root
If you want your colleagues to use the same language
What to do if you can't use WiFi on Linux
What to do if you lose your EC2 key pair
What to do if you get an error saying c compiler cannot create executables in configure