unix equivalent of python's os.add_dll_directory

Viewed 195

I found a python program on the web that plays video in a wxPython panel. I want to use it on Unix, but it has a Windows-specific call in it:

os.add_dll_directory(r'C:\Program Files\VideoLAN\VLC')

This adds the given directory (to a list?) so that it is searched for necessary DLLs.

I know Unix has an environment variable LD_DIRECTORY_PATH that does a similar thing; I don't know whether the VLC library I'm using would use it the same way as the directory in the add_dll_directory call.

I searched the target unix system for what seemed to be the primary DLL filename to try to locate a directory that way, but did not find it. The VLC program is installed on the unix machine, and plays videos just fine, but the program using the python-vlc module fails when it is time to load the video.

Can someone help me figure out what to add to the unix program to duplicate this?

1 Answers

The environment variable on unix is LD_LIBRARY_PATH. You can try setting this in the Python session's environment like this:

import os
os.environ["LD_LIBRARY_PATH"] = "/path/to/vlc/libraries"

To be nice, you should probably check if it's already set and append to any existing path, separated by :.

Anything run under that Python session should inherit the environment and should find the libraries but I can't say that I've never seen this fail to work from time to time.

Related