Many of the Plex executables want a couple of environment variables set before they’ll run; are you doing that?
See the start.sh script that comes with Plex. Or see comments in this thread:
Media scanner cli is crashing [fixed] - needed env variable set
But also, really, consider using the web requests API or the Python PlexAPI.