Mopidy Setup Issues - Python version requirement


#1

I read through this older post - Python error when starting Mopidy on Raspberry Pi

It refers to ensuring that one use the correct version of pip (one that uses Python 2.7). I’m not sure this is relevant based on the current state of Mopidy in that the installation process does not use pip currently.

I flashed a new environment on my RPi3B for my AIY Voice Kit. It is running Linux raspberrypi 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux

I went through the Mopidy installation procedure outlined here - https://docs.mopidy.com/en/latest/installation/debian/#debian-install

I am now attempting to create and edit the mopidy.conf file. When I invoke mopidy in the terminal window, I get the error message about Mopidy requiring Python 2.7.

“Mopidy requires Python 2.7, but found 3.2.4”

I checked the image and Python 2.7 is present.

I am relatively inexperienced with Linux, but it occured to me to try to create a virtual environment in my home directory (/home/pi) (virtualenv -p /usr/bin/python2.7 mopidy/env) to see if Mopidy would then “see” Python 2.7. After activating the environment, I tried running ‘mopidy config’ again. Alas, this did not solve the issue.

To prepare for installing Mopidy on the AIY Voice Kit, I recently went through a complete installation of the most current version of Raspian. I flashed Raspian Stretch. I installed and configured Mopidy, Mopidy-Spotify, and Mopidy-TuneIn. Throughout this process, logged in as user ‘pi’, I did not encounter this issue.

Today I flashed the AIY Voice Kit image on an SD card. I have that image up and running and I am logged in as ‘pi’. Following the Mopidy installation process exactly as I did with the “vanilla” Raspbian, gave this Python version error from Mopidy. This environment’s Raspian software must be deployed slightly differently that a “vanilla” Raspian installation, obviously.

How do I get Mopidy to see Python 2.7?

Thanks.

Mike


#2

It sounds like the AIY voice kit image has decided to install python3 as the default python version. What is the output of which python and version of that binary?

Mopidy (rightly) expects /usr/bin/python to be python2.7, not 3. You could try modifying /usr/bin/mopidy to point to /usr/bin/python2.7

EDIT: But a 2.7 virtualenv should work. Can you run mopidy deps in the virtualenv?


#3

This is pretty much why i developed a docker container for mopidy.
Inside the container mopidy finds everything it needs and is independent from the host system.
What do you need?

Docker (obviously):
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh

Run the container:
docker run -d --name mopidy --net host --device /dev/snd -v ~/.config/mopidy/mopidy.conf:/root/.config/mopidy/mopidy.conf -v /data/music:/data/music rawdlite/mopidy_armhf

We might need to adapt some of the path to your system.
Let me know if you are interested and i walk you through.

cheers


#4

Yes, trying to install Mopidy as it would want and not need to tweak it if possible. The AIY Voice Kit is pretty “standard” Raspian so I don’t understand why this is happening. The environment contains Python 2.7 as well as Python 3.4.2. Mopidy ought to be able to the Python version it wants.

pi@raspberrypi:~ $ which python
/usr/bin/python
pi@raspberrypi:~ $ ls -la /usr/bin/python
lrwxrwxrwx 1 root root 9 Mar 28  2015 /usr/bin/python -> python2.7
pi@raspberrypi:~ $ mopidy config
ERROR: Mopidy requires Python 2.7, but found 3.4.2.

Here is the process I used to create a Python 2.7 virtual environment:

pi@raspberrypi:~ $ virtualenv -p /usr/bin/python2.7 mopidy/env
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in /home/pi/mopidy/env/bin/python2.7
Also creating executable in /home/pi/mopidy/env/bin/python
Installing setuptools, pip, wheel...done.
pi@raspberrypi:~ $ source mopidy/env/bin/activate
(env) pi@raspberrypi:~ $ mopidy deps
ERROR: Mopidy requires Python 2.7, but found 3.4.2.

#5

@rawdlite,

Docker sounds like an interesting approach. As a noob, I probably need to pass my Linux 101 first though. I will take a raincheck and follow up when I get around to “advanced topics” :wink:

I probably will play with this on my hobby RPi rather than this AIY kit. I hope to stabilize “development” on this Voice Kit after I add Spotify and TuneIn capabilities. The current voice recognition API does not have these integrations like their the commercial Google Home products do. I have added limited radio capability via voice control using mpd. Mopidy (with Spotify and TuneIn) will expand that considerably.

Thanks for the offer. I’ll be in touch. It might be several weeks what with my Linux 101 learning curve and finding “hobby time” when I’m not doing my day job :frowning:

Cheers!

Mike


#6

I don’t understand what’s going on there. I have a aiy kit somewhere gathering dust, I am curious to what’s going on, will try it when I get a chance.


#7

Thanks Nick. Some environment variable or path definition slightly awry. But I can’t see anything obvious. Of course, it will be once the problem is identified :wink:


#8

Did a little more digging and found that Mopidy was installed under Python 2.7 AND Python 3. I installed Mopidy ONCE with apt-get install steps as in the documentation. Not sure how that Python 3 package got there. To resolve the issue I flashed the AIY image again and re-installed Mopidy. The only thing I recall doing differently is that I ran Mopidy from a terminal window first before starting it as a service. Earlier I got cocky and went straight for running Mopidy as a service straight away.

In any case, the issue is now resolved.


#9

I figured out what is causing this. I went through my Mopidy setup one component at a time. First Mopidy itself. All’s well. Then the Spotify backend extension. Still good. But then I installed the TuneIn backend extension and, voila!, Python version problem. I followed the installation instructions installing the TuneIn extension via ‘sudo pip install Mopidy-TuneIn’. Bingo - Mopidy is now installed in both the Python 3 and the Python 2.7 paths… and attempting to start Mopidy results in the error about the wrong Python version.

What about that installation command resulted in a “duplicate” Mopidy installation? Did I do something wrong?

I then tried to uninstall the TuneIn extension ‘sudo pip uninstall Mopidy-TuneIn’ but this did not fully clean up the issue and now Mopidy won’t start up. What do I need to do to remove the “extra” installation in the Python 3 path? And once that’s rectified, how can I install the TuneIn extension properly?

This issue appears to be related to the Raspbian version/setup in the AIY image. When I installed Raspbian from the latest download on the Foundation’s website, I was able to install TuneIn and use it fine (other than the incompatible streams issue).

Regards.

Mike