Plex_Autoscan with Ubuntu 20.04

Hi guys.

I upgraded my ubuntu from 18.04 to 20.04.

When I try to run ./scan.py from /opt/plex_autoscan/ I get this error:

Traceback (most recent call last):
File "./scan.py", line 8, in
from pyfiglet import Figlet
File "/usr/local/lib/python2.7/dist-packages/pyfiglet/init.py", line 11, in
import pkg_resources
ImportError: No module named pkg_resources

I read that Python2.7 is no longer supported in 20.04, så Python3 needs to be installed.

Installed Python3 and ran:

sudo python3 -m pip install -r requirements.txt
python3 scan.py sections

All that seems to work, but when I want to start my plex_autoscan.service I get this:
plex_autoscan.service - Plex Autoscan
Loaded: loaded (/etc/systemd/system/plex_autoscan.service; disabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Mon 2020-10-05 14:52:23 CEST; 4s ago
Process: 93775 ExecStart=/opt/plex_autoscan/scan.py server --loglevel=INFO (code=exited, status=1/FAILURE)
Main PID: 93775 (code=exited, status=1/FAILURE)

Oct 05 14:52:23 plex-NUC8i3BEH scan.py[93775]: import pkg_resources
Oct 05 14:52:23 plex-NUC8i3BEH scan.py[93775]: ImportError: No module named pkg_resources
Oct 05 14:52:23 plex-NUC8i3BEH systemd[1]: plex_autoscan.service: Main process exited, code=exited, status=1/FAILURE
Oct 05 14:52:23 plex-NUC8i3BEH systemd[1]: plex_autoscan.service: Failed with result 'exit-code'.

Any ideas to sort this out?

Thanks

hi,

change --loglevel=INFO to --log-level=INFO

It's not rclone so changing that would break it as it wants --loglevel.

What's your service file look like?

Hi guys .

First I tried asddffsa , same result.

plex_autoscan.service:

[Unit]
Description=Plex Autoscan
After=network-online.target

[Service]
User=plex
Group=plex
Type=simple
WorkingDirectory=/opt/plex_autoscan/
ExecStart=/opt/plex_autoscan/scan.py server --log-level=INFO
Restart=always
RestartSec=10

[Install]
WantedBy=default.target

If I run manually.

./scan.py server

Traceback (most recent call last):
File "./scan.py", line 8, in
from pyfiglet import Figlet
File "/usr/local/lib/python2.7/dist-packages/pyfiglet/init.py", line 11, in
import pkg_resources
ImportError: No module named pkg_resources

Bit confusing as you are running some commands as root and your service file uses the plex user.

You want to install the requirements as the user you intend to run it as.

I use my user felix so I install the requirements as felix and my service file reflects that.

# /etc/systemd/system/plex_autoscan.service

[Unit]
Description=Plex Autoscan
After=network-online.target

[Service]
User=felix
Group=felix
Type=simple
WorkingDirectory=/opt/autoscan/
ExecStart=/usr/bin/python3 /opt/autoscan/scan.py server --loglevel=INFO
Restart=always
RestartSec=10

[Install]
WantedBy=default.target

You want to explicitly use python3 in your service file as you probably have both on your server.

1 Like

Why didnt I think of that :slight_smile:

@Animosity022 YOU are simply the best. Its running now .

Thanks so much for your assistance , this saved my day :slight_smile:

Kind regards

Morph

sorry, still on first coffee of a monday morning.

1 Like

Sweet.

You reminded me to migrate Tautulli to python3 as that was my last straggler and that's done now too so win-win for us.

1 Like

:slight_smile: indeed .

Did a total upgrade today. Then I also got the latest version of rutorrent ^^ heh

It was worth a shot mate :slight_smile:

Your help was appreciated .