Python Forum

Full Version: How to set LD_LIBRARY_PATH on python codes?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using eclipse ide. So I configure LD_LIBRARY_PATH environment variable on eclipse ide. But I try to generate python codes which are independent on development ide. I want to generate codes which export environment variables on python codes dynamically. These are my sample codes.

import os, sys
import subprocess

my_env = os.environ.copy()
my_env["LD_LIBRARY_PATH"] = "/home/joseph/hadoop/lib/native"

subprocess.Popen('export', env=my_env)
But these codes throws exception,

Error:
FileNotFoundError: [Errno 2] No such file or directory: 'export'
I also try to execute
os.execv('export', ['LD_LIBRARY_PATH'])
But fail again.
Kindly inform me how to configure LD_LIBRARY_PATH variable on python codes. Best regards.
did you try just
os.environ["LD_LIBRARY_PATH"] = "/home/joseph/hadoop/lib/native"
as per the docs:
Quote:This mapping may be used to modify the environment as well as query the environment. putenv() will be called automatically when the mapping is modified.