python - Change current process environment's LD_LIBRARY_PATH -
Is it possible to change the environmental variable of the current process?
I especially want to change the LD_LIBRARY_PATH in a python script so that a module relies on some xyz.so on the import of 'x' xyz.so has been taken from the given path in the LD_LIBIRRBRRAPHTH
Is there any way to change the dynamic way from which the library loads?
Edit : I think I need to tell that I already have OS. Environment ["LD_LIBRIAPH"] = MAYPATH has tried like OSPNAV ('LD_LIBRIAPHH', MYPATH), but these env For the spontaneous sub-process, not the current process, and module loading does not consider the new LD_LIBIRRAABABRATH
Edit2 , so the question is whether we can change the environment or Something from which the library loader sees it and loads from there?
Reasons
os Environ ["LD_LIBRARY_PATH"] = .. . does not work: it's the behavior of variable dynamic loader control behavior ( ld-linux.so.2 on linux, ld.so .1 on Solaris), but the loader only sees the LD_LIBRARY_PATH at the process startup. After << em>, there is no effect of that point (just to answer the question) changing the value of LD_LIBRARY_PATH .
You have some options:
If you know that you have xyz.so to / some / path , and to control the execution of Python scripts from the beginning, just set LD_LIBRARY_PATH for your choice (after checking it is not already set), And execute yourself again, this is what java does.
B. You can import /some/path/xyz.so through your entire path before import x.so . When you import x.so , the loader will find that it has already loaded xyz.so , and to search it again Instead will use the preloaded module. / P>
If you create x.so by yourself, you can add -Wl, -rpath = / some / path to its link line , And then the x.so loader will be the reason for seeing dependent modules in / some / path .
Comments
Post a Comment