Mopidy is (self-proclaimed:) "an extensible music server written in Python." Since it plays music from a variety of sources and could be controlled by a multitude of clients this sounds like a cool way to give the Raspberry Pi a second use as a Music Jukebox.

On Arch Linux I followed the instructions to the letter but mopidy is not running but throwing this error upon start:

ERROR: Mopidy requires Python 2.7, but found 3.4.3.

I have both python2.7 and python3 installed and suspect this to be a problem.

Mopidy 3.0, as released in December 2019, now requires Python 3.7 or newer.


So mopidy wants python2.7. Ok, that's fine with me after all both versions are installed. /usr/bin/mopidy however starts with #!/usr/bin/python which is typically a symlink to /usr/bin/python3 if both python2.7 and python3 are installed.

So the first fix is to change #!/usr/bin/python to #!/usr/bin/python2 in /usr/bin/mopidy.

Try to run mopidy again - still not working:

Traceback (most recent call last):
  File "/usr/bin/mopidy", line 7, in <module>
    from mopidy.__main__ import main
ImportError: No module named 'mopidy'.__main__

What's wrong now? Turns out the the packages (mopidy, pykka, certifi, setuptools and tornado) are installed to /usr/lib/python3.4/site-packages by running pip install -U mopidy and are therefore not found by python2.7. To fix this it is necessary to not call pip but pip2 as it will install packages to the library path of python2.7 /usr/lib/python2.7/site-packages. Check this by calling pip -V or pip2 -V which returns something like pip 6.1.1 from /usr/lib/python3.4/site-packages (python 3.4) and pip 6.1.1 from /usr/lib/python2.7/site-packages (python 2.7) respectively.

So the second issue is to pip2 install -U mopidy instead of pip install -U mopidy.

(The latter seems pretty obvious given the fact that mopidy runs with python2.7 but is still a little pitfall one could stumble about.)

Now you should have a mopidy jukebox up and running.

| improve this answer | |
  • If /usr/bin/python was a symlink to /usr/bin/python3 then it violates the recommendation in PEP 394 at the time, although as Python 2 is nearing its end of life there seems to be some change in the PEP. – Milliways Jan 5 at 5:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.