Mopidy Setup Issues - Python version requirement

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

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?

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

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.

@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

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.

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:

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.

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

Any ideas why the TuneIn install is causing the issue?

Do you have the install log for it to see which particular part started going wrong? There’s really not much to the tunein extension, I think it only depends on requests (as mopidy-spotify also does so that dependency should already be satisfied anyway). Did you install mopidy-spotify from pip or apt?

Where is the installation log located?

Sorry, I just mean what pip prints to the screen as it installs mopidy-tunein

Well… it’s frustrating when things suddenly work and apparently nothing changed.

I ran through the entire setup: Flash AYI image; Install Mopidy; Install Spotify extension; Install TuneIn extension. As soon as TuneIn installed, the script appeared in both Python paths (2.7 and 3). HOWEVER, this time Mopidy start up fine. The only thing I did differently this time is to not try to start up Mopidy until after I had installed TuneIn. I don’t know if this made a difference (hard to believe that it did). Something was different. Unless someone modified the TuneIn installation package since I tried this earlier this month. Otherwise, I cannot explain it.

In any case. Here is the output from the installation of TuneIn. It shows the script showing up only in Python 2.7 and then also in Python 3 after TuneIn is installed.

pi@raspberrypi:~ $ sudo grep -rnw '/' --include \*.py -e "Mopidy requires Python 2.7"
/usr/lib/python2.7/dist-packages/mopidy/__init__.py:10:        'ERROR: Mopidy requires Python 2.7, but found %s.' %

pi@raspberrypi:~ $ mopidy deps
Executable: /usr/bin/mopidy
Platform: Linux-4.9.35-v7+-armv7l-with-debian-8.0
Python: CPython 2.7.9 from /usr/lib/python2.7
Mopidy: 2.1.0 from /usr/lib/python2.7/dist-packages
  Pykka>=1.1: 1.2.1 from /usr/lib/python2.7/dist-packages
  requests>=2.0: 2.4.3 from /usr/lib/python2.7/dist-packages
  tornado>=3.2: 3.2.2 from /usr/lib/python2.7/dist-packages
Mopidy-Spotify: 3.1.0 from /usr/lib/python2.7/dist-packages
  Mopidy>=2.0: 2.1.0 from /usr/lib/python2.7/dist-packages
    Pykka>=1.1: 1.2.1 from /usr/lib/python2.7/dist-packages
    requests>=2.0: 2.4.3 from /usr/lib/python2.7/dist-packages
    tornado>=3.2: 3.2.2 from /usr/lib/python2.7/dist-packages
  Pykka>=1.1: 1.2.1 from /usr/lib/python2.7/dist-packages
  pyspotify>=2.0.5: 2.0.5 from /usr/lib/python2.7/dist-packages
    cffi>=1.0.0: 1.1.2 from /usr/lib/python2.7/dist-packages
      pycparser: 2.10 from /usr/lib/python2.7/dist-packages
  requests>=2.0: 2.4.3 from /usr/lib/python2.7/dist-packages
GStreamer: 1.4.4.0 from /usr/lib/python2.7/dist-packages/gi
  Detailed information: 
    Python wrapper: python-gi 3.14.0
    Relevant elements:
      Found:
        uridecodebin
        souphttpsrc
        appsrc
        alsasink
        osssink
        oss4sink
        pulsesink
        id3demux
        id3v2mux
        lamemp3enc
        mad
        mpegaudioparse
        mpg123audiodec
        vorbisdec
        vorbisenc
        vorbisparse
        oggdemux
        oggmux
        oggparse
        flacdec
        flacparse
        shout2send
      Not found:
        flump3dec

pi@raspberrypi:~ $ sudo pip install Mopidy-TuneIn
Collecting Mopidy-TuneIn
  Downloading Mopidy_TuneIn-0.4.1-py2.py3-none-any.whl
Collecting Mopidy>=1.1 (from Mopidy-TuneIn)
  Downloading Mopidy-2.1.0-py2.py3-none-any.whl (210kB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 215kB 703kB/s 
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from Mopidy-TuneIn)
Requirement already satisfied: requests>=2.0.0 in /usr/lib/python3/dist-packages (from Mopidy-TuneIn)
Collecting Pykka>=1.1 (from Mopidy-TuneIn)
  Downloading Pykka-1.2.1-py2.py3-none-any.whl
Collecting tornado>=3.2 (from Mopidy>=1.1->Mopidy-TuneIn)
  Downloading tornado-4.5.3.tar.gz (484kB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 491kB 273kB/s 
Collecting backports_abc>=0.4 (from tornado>=3.2->Mopidy>=1.1->Mopidy-TuneIn)
  Downloading backports_abc-0.5-py2.py3-none-any.whl
Building wheels for collected packages: tornado
  Running setup.py bdist_wheel for tornado ... done
  Stored in directory: /root/.cache/pip/wheels/0c/21/02/8cdc6a381450df92b449ea7c57be653dd7aa80ba42c716212c
Successfully built tornado
Installing collected packages: backports-abc, tornado, Pykka, Mopidy, Mopidy-TuneIn
Successfully installed Mopidy-2.1.0 Mopidy-TuneIn-0.4.1 Pykka-1.2.1 backports-abc-0.5 tornado-4.5.3

pi@raspberrypi:~ $ sudo grep -rnw '/' --include \*.py -e "Mopidy requires Python 2.7"
/usr/local/lib/python3.4/dist-packages/mopidy/__init__.py:10:        'ERROR: Mopidy requires Python 2.7, but found %s.' %
/usr/lib/python2.7/dist-packages/mopidy/__init__.py:10:        'ERROR: Mopidy requires Python 2.7, but found %s.' %

pi@raspberrypi:~ $ mopidy deps
Executable: /usr/bin/mopidy
Platform: Linux-4.9.35-v7+-armv7l-with-debian-8.0
Python: CPython 2.7.9 from /usr/lib/python2.7
Mopidy: 2.1.0 from /usr/lib/python2.7/dist-packages
  Pykka>=1.1: 1.2.1 from /usr/lib/python2.7/dist-packages
  requests>=2.0: 2.4.3 from /usr/lib/python2.7/dist-packages
  tornado>=3.2: 3.2.2 from /usr/lib/python2.7/dist-packages
Mopidy-Spotify: 3.1.0 from /usr/lib/python2.7/dist-packages
  Mopidy>=2.0: 2.1.0 from /usr/lib/python2.7/dist-packages
    Pykka>=1.1: 1.2.1 from /usr/lib/python2.7/dist-packages
    requests>=2.0: 2.4.3 from /usr/lib/python2.7/dist-packages
    tornado>=3.2: 3.2.2 from /usr/lib/python2.7/dist-packages
  Pykka>=1.1: 1.2.1 from /usr/lib/python2.7/dist-packages
  pyspotify>=2.0.5: 2.0.5 from /usr/lib/python2.7/dist-packages
    cffi>=1.0.0: 1.1.2 from /usr/lib/python2.7/dist-packages
      pycparser: 2.10 from /usr/lib/python2.7/dist-packages
  requests>=2.0: 2.4.3 from /usr/lib/python2.7/dist-packages
GStreamer: 1.4.4.0 from /usr/lib/python2.7/dist-packages/gi
  Detailed information: 
    Python wrapper: python-gi 3.14.0
    Relevant elements:
      Found:
        uridecodebin
        souphttpsrc
        appsrc
        alsasink
        osssink
        oss4sink
        pulsesink
        id3demux
        id3v2mux
        lamemp3enc
        mad
        mpegaudioparse
        mpg123audiodec
        vorbisdec
        vorbisenc
        vorbisparse
        oggdemux
        oggmux
        oggparse
        flacdec
        flacparse
        shout2send
      Not found:
        flump3dec

Maybe there’s a clue in there.

Cheers!

Mike