Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add an environment variable LD_LIBRARY_PATH to the python code and effective #100567

Open
zjl767864079zjl opened this issue Dec 28, 2022 · 0 comments
Labels
expert-ctypes type-bug An unexpected behavior, bug, or error

Comments

@zjl767864079zjl
Copy link

zjl767864079zjl commented Dec 28, 2022

I add LD_LIBRARY_PATH to the python code like:

test.py

import os
from ctypes import CDLL

os.environ['LD_LIBRARY_PATH'] = "/home/test/myfolder/pyfolder/ztools1226/lib"
print(os.environ)
s_dll_path = f"/home/test/myfolder/pyfolder/ztools1226/lib/libCityPlanParse.so"
dll_load = CDLL(s_dll_path)

I print the os.environ the LD_LIBRARY_PATH value already exists,but when I CDLL /home/test/myfolder/pyfolder/ztools1226/lib/libCityPlanParse.so report an error:
OSError: libCityPlanParse.so: cannot open shared object file: No such file or directory

But when I join in the command-line "export LD_LIBRARY_PATH=/home/test/myfolder/pyfolder/ztools1226/lib" before executing test.py,program execution ok.

So the environment variable I added in the code is not take effect.But I need to do that.How can I write about it to take effect?

My environment

python 3.8.3
Linux system

@zjl767864079zjl zjl767864079zjl added the type-bug An unexpected behavior, bug, or error label Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expert-ctypes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants