0

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.

MikeBHouston
  • 1
  • 1
  • 1
  • Have you tried doing the same export statements but leaving the trailing `/` off? – Carlos Aug 17 '17 at 21:05
  • Check which `python` runs when you run it as `root` and as user `plex`. Then update `script.sh` with the full path of the python. – alvits Aug 18 '17 at 02:49
  • Tried both suggestions of removing trailing '/ off the PYTHONPATH and PYTHONHOME. No change in the result. I've also tried including the full path to python as /usr/bin/python (root) and /bin/python (plex user). Neither of these makes a difference. – MikeBHouston Aug 18 '17 at 13:32

0 Answers0