Setup Couchpotato with virtualenv

I run Couchpotato on my media server and since the project isn’t actively maintained it doesn’t run on python3. My linux os dropped having pip2.7 available by default likely to encourage people to migrate to python3, I decided to run it in a python virtual environment to break the apps dependency on the system python support. Below are the steps I took to get it running.

Setup virtualenv

Python3 comes with venv or creating virtual enviroments but venv doesn’t support creating environments with python2.7. Current versions of virtualenv also don’t support python2.7 so we have to install a version that has this support we will go with version 20.21.1

pip install virtualenv==20.21.1

Create your virtual environment directory I created this inside the couchpotato project but you can also place it outside if you intend to use it with more than one project.

mkdir couchpotatoserver/.venv/

Point the virtualenvironment to the actual path of your python2.7 binary

virtualenv --python=/usr/bin/python2.7 /<path>/couchpotatoserver/.venv/

This will install python2.7 and a compatible pip version in the virtual environment.

Use virtualenv

You should be able to install all your needed dependencies from the couchpotato requirements file with the pip cmd. Use the path to the pip binary to make sure the dependencies get installed in your virtual environment and not the OS.

.venv/bin/pip install -r requirements-dev.txt

Just as we had to install a specific version of virtualenv which supports Python2.7 we will need to install specific versions of 2 other libraries needed by couchpotato in our virtual environment.

.venv/bin/pip install cryptography==2.2.2
.venv/bin/pip install PyOpenSSL==17.5.0

Update whichever script you are using to startup couch potato to use the Python installed in the virtual environment, it is very important to reference the actual path otherwise by omitting the path you will be using the system level Python version which will cause startup to fail.

/<root-path>/couchpotatoserver.venv/bin/python /apps/couchpotatoserver/CouchPotato.py

You should now be able to startup your couchpotato service using your virtual environment and should be safe from future OS updates breaking your setup. This documentation assumes you already have an existing couchpotato setup already, the setup of couchpotato is outside scope of this notes.

Upgrading CentOS

Do a back up a recoverable system backup or a backup for all important docs you have on system before you proceed with the commands below

yum clean all
yum update glibc\*
yum update yum\* rpm\* python\*
yum clean all
yum update
reboot

Check  your  new version with :

lsb_release  -a