I'm trying to create a word cloud out of subtitle text using python wordcloud_cli.py as a component of my postprocessing script within Plex Media Server. Just a fun little test. But I cannot get the python part of it to work when executing as the plex user. I'm using CentOS 7 x64, latest version of Plex Media Server and Python 2.7.5.
Basically my script.sh is formatted like this:
#!/bin/sh
file="$1"
source="${file%.*}"
ffmpeg (code to extract subtitles and create .srt file)
python /usr/bin/wordcloud_cli.py --text /var/lib/plexmediaserver/${source}.srt --imagefile var/lib/plexmediaserver/${source}_wordcloud.png --width 1280 --height 540 --margin 15
When I execute this script as root on the machine it works flawlessly. When I switch user using..
su - plex
...and execute script using "./script.sh file.ts" it works flawlessly.
But when I allow PMS to run the script from the DVR settings box and I watch the systemctl journal, I see this...
Aug 15 14:00:18 Plex.localdomain sh[2657]: Wordcloud_cli starting
Aug 15 14:00:18 Plex.localdomain sh[2657]: Could not find platform independent libraries <prefix>
Aug 15 14:00:18 Plex.localdomain sh[2657]: Could not find platform dependent libraries <exec_prefix>
Aug 15 14:00:18 Plex.localdomain sh[2657]: Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Aug 15 14:00:18 Plex.localdomain sh[2657]: ImportError: No module named site
I've made progress by inserting the following into the top of my script..
export PYTHONPATH=/usr/lib64/
export PYTHONHOME=/usr/
Now when I run it, I only get...
ImportError: No module named site.
This warning does not happen when I run it manually as root or su - plex.