I use a Python application called MyMedia to stream videos from my Ubuntu media server to my Roku boxes.
I installed Ubuntu 20 yesterday. The painfully slow navigation problem (caused by the slow but inevitable deprecation of python 2) re-appeared, and I tried to re-create the fix. Initially, I just succeeded in preventing MyMedia from running at all.
Here is what actually worked.
- First, I copied all of my backed up MyMedia files to
/usr/local/bin/mymedia
- Then I installed python 2.7…
sudo apt-get install python2
- Then I installed pip, but first I had to install curl…
sudo apt-get install curl
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
sudo python2 get-pip.py
- Then I installed Pillow
sudo python2 -m pip install --upgrade Pillow
- It might not have been necessary, but I installed several image libraries…
sudo apt-get install libjpeg-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
sudo apt-get install zlib1g-de
sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
- In
common.py
, I made sure that this… import Image
- … had been replaced with this…
#import Image
from PIL import Image
Huge success!
Note that during this process, I got several warnings about Python 2.7 being deprecated, like this one:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
It’s only a matter of time before MyMedia becomes unusable. I would love to get access to the git repository and try to update it for Python 3, if that’s possible. I’ve asked, but the original developer is no longer associated with the project. It may be that I’ll have to find a new solution to this problem in a year or so.
Also, I have updated my init script (/etc/init.d/memedia
), which runs mymedia in a screen …
#!/bin/sh
### BEGIN INIT INFO
# Provides: minidlna
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: mymedia server
# Description: mymedia media server.
### END INIT INFO
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
DESC="MyMedia media server"
MEDIAPATH=/var/media
DAEMONPATH=/usr/local/bin/mymedia/server
DAEMON=$DAEMONPATH/mymedia.py
SCRIPTNAME=/etc/init.d/mymedia
SCREENNAME=mymedia
USER=bblackmoor
GROUP=media
EXECUSER=root
EXECGROUP=media
case "$1" in
start)
chown -R $EXECUSER:$EXECGROUP $DAEMONPATH
chown -R $USER:$GROUP $MEDIAPATH
su - $USER -c "cd $DAEMONPATH; screen -dm -S $SCREENNAME python2 $DAEMON"
;;
stop)
su - $USER -c "screen -S $SCREENNAME -X quit"
su - $USER -c "screen -wipe"
;;
status)
su - $USER -c "screen -list | grep $SCREENNAME"
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status}" >&2
exit 3
;;
esac
: