Upgrading to Python 3 (Tautulli v2.5) - mrvaghani/Tautulli GitHub Wiki

Operating Systems:


Windows / macOS

Important changes

Running Tautulli in the background on startup can be enabled by checking Tautulli Settings > Web Interface > Launch at System Startup.

  • Warning: Make sure to remove any previous Tautulli shortcut from your startup folder or task in Windows Task Scheduler on Windows, or .plist files in your LaunchAgents folder on macOS, to prevent conflicts with the Tautulli setting! Refer to the deprecated instructions in the Install as a Daemon page.

Reinstalling Tautulli using the app installer (recommended)

  • Tautulli v2.5 and above can be installed on Windows or macOS (10.14 or newer) without needing to install Python. You can download the new Windows .exe or macOS .pkg installer from the GitHub Releases page.

Instructions:

  1. Go to the Tautulli Settings > Help & Info page.
  2. Click on the "Database File" link to download a copy of your Tautulli database.
  3. Click on the "Configuration File" link to download a copy of your Tautulli configuration.
  4. Shutdown Tautulli.
  5. Install Tautulli using the Windows .exe or macOS .pkg installer.
  6. Start Tautulli and complete the setup wizard.
  7. Go to the Tautulli Settings > Import & Backup page and re-import the database file (using the "Overwrite" method) and configuration file that you saved in the steps above.
  8. Once you have the database imported and Tautulli successfully configured, you may uninstall the previous version of Tautulli by deleting the old folder (Windows: C:\Tautulli or macOS: /Applications/Tautulli).

Notes:

  • Python still needs to be installed if you are running Python script notifications.
  • To update Tautulli using the app installer, just download and run the new installer when a new update is available.

Linux

Reinstalling Tautulli using the Snap package (recommended)

  • Tautulli v2.6.3 and above can be installed on most Linux distributions using the Snap package without needing to install Python.

Instructions:

  1. Go to the Tautulli Settings > Help & Info page.
  2. Click on the "Database File" link to download a copy of your Tautulli database.
  3. Click on the "Configuration File" link to download a copy of your Tautulli configuration.
  4. Shutdown Tautulli.
  5. Install Tautulli using snap by following the Installation instructions.
  6. Start Tautulli and complete the setup wizard.
  7. Go to the Tautulli Settings > Import & Backup page and re-import the database file (using the "Overwrite" method) and configuration file that you saved in the steps above.
  8. Once you have the database imported and Tautulli successfully configured, you may uninstall the previous version of Tautulli by deleting the old folder (/opt/Tautulli) and the old service file (/lib/systemd/system/tautulli.service).

Notes:

  • Python still needs to be installed if you are running Python script notifications.
  • Snap packages update automatically outside of Tautulli.

Modifying an existing Tautulli install (alternative)

  • This will update an existing Tautulli systemd service script that is using Python 2 to Python 3.

Instructions:

  1. Make sure Tautulli is shutdown or run sudo systemctl stop tautulli.service.
  2. Get the path to your python3 interpreter using command -v python3.
    • Note: You may need to replace python3 with the correct value for your system (e.g. python3.7).
  3. Edit /lib/systemd/system/tautulli.service.
  4. Add the path to your python3 interpreter from step 1 to the start of the ExecStart= command (e.g. /usr/bin/python3).
    • Example:
      ExecStart=/usr/bin/python3 /opt/Tautulli/Tautulli.py --config /opt/Tautulli/config.ini --datadir /opt/Tautulli --quiet --daemon --nolaunch
      
  5. Start Tautulli with sudo systemctl daemon-reload && sudo systemctl start tautulli.service.

Notes:

  • If Tautulli will not start with the error ImportError: bad magic number in 'pkg_resources', run the clean_pyc.sh file inside the Tautulli contrib folder.
    cd /opt/Tautulli/contrib
    ./clean_pyc.sh
    

FreeBSD / FreeNAS

Modifying an existing Tautulli install

  • This will update an existing Tautulli service script that is using Python 2 to Python 3.

Instructions:

  1. Make sure Tautulli is shutdown or run service tautulli stop.
  2. Install all the prerequisites from the Installation instructions.
  3. Remove the old symbolic link to Python 2 with rm /usr/local/bin/python.
  4. Create a new symbolic link to Python 3 with ln -s /usr/local/bin/python3 /usr/local/bin/python.
  5. Check the python version with python -V and it should say Python 3.7.x.
  6. Edit /usr/local/etc/rc.d/tautulli.
  7. Add command_interpreter="python" above the command line (line 41).
    • Example:
      command_interpreter="python"
      command="${tautulli_dir}/Tautulli.py"
      command_args="--daemon --pidfile ${tautulli_pid} --quiet --nolaunch ${tautulli_flags}"
      
  8. Start Tautulli with service tautulli start.

Troubleshooting:

1.) If Tautulli will not start with the error ImportError: bad magic number in 'pkg_resources', run the clean_pyc.sh file inside the Tautulli contrib folder.

cd /usr/local/share/Tautulli/contrib
./clean_pyc.sh

If you are inside a jail or something similar that doesn't offer bash shell, the script will fail with the following error:

root@tautulli:/usr/local/share/Tautulli/contrib # ./clean_pyc.sh
env: bash: No such file or directory

find out what shell is available to you and run the clean up command manually

root@tautulli:/usr/local/share/Tautulli/contrib # cat /etc/shells
# $FreeBSD: releng/11.4/etc/shells 59717 2000-04-27 21:58:46Z ache $
#
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/sh
/bin/csh
/bin/tcsh
/usr/local/libexec/git-core/git-shell

We will use "/bin/csh"

cd /usr/local/share/Tautulli/contrib
/bin/csh -c 'find "`dirname $0`/.." -type f -name "*.pyc" -exec rm -rf {} \;'

Try starting the service again and it should start

service tautulli start

2.) While installing prerequisites, if you get an error pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2 similar to this:

root@tautulli:/ # pkg install python py38-setuptools py38-sqlite3 py38-openssl py38-pycryptodomex security/ca_root_nss git-lite
Updating FreeBSD repository catalogue...
[tautulli] Fetching meta.txz: 100%    916 B   0.9kB/s    00:01
pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
repository FreeBSD has no meta file, using default settings
[tautulli] Fetching packagesite.txz: 100%    6 MiB   2.0MB/s    00:03
pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2  # Error
pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0
Unable to open created repository FreeBSD
Unable to update repository FreeBSD
Error updating repositories!

Run this to fix the error:

root@tautulli:/ # pkg bootstrap -f
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: Y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:11:amd64/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
[tautulli] Installing pkg-1.16.3...
package pkg is already installed, forced install
[tautulli] Extracting pkg-1.16.3: 100%