import - Set LD_LIBRARY_PATH before importing in python -


python uses pythonpath environment-variable determine in folders should modules. can play around modifying sys.path, works nicely pure python-modules. when module uses shared object files or static libraries, looks in ld_library_path (on linux), can't changed , platform dependent far know.

the quick-fix problem of course set environment-variable or invoke script ld_library_path=. ./script.py, you'll have set again every new shell open. also, .so files in case in same directory .py file, may moved absolute path, i'd set them automatically every time invoke script.

how can edit path in python interpreter looks libraries platform-independently on runtime?

edit:

i tried os.environ['ld_library_path'] = os.getcwd(), no avail.

i use:

import os  os.environ['ld_library_path'] = os.getcwd()  # or whatever path want 

this sets ld_library_path environment variable duration/lifetime of execution of current process only.

edit: looks needs set before starting python: changing ld_library_path @ runtime ctypes

so i'd suggest going wrapper .sh (or .py if insist) script. also, @chepner pointed out, might want consider installing .so files in standard location (within virtualenv).

see setting ld_library_path inside python


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -