Can't run mopidy on fresh brew install getting python framework error

Here is the error I’m getting:

Traceback (most recent call last):
File “/usr/local/bin/mopidy”, line 5, in
from pkg_resources import load_entry_point
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 3095, in
@_call_aside
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 3081, in _call_aside
f(*args, **kwargs)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 3108, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 658, in _build_master
ws.require(requires)
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 959, in require
needed = self.resolve(parse_requirements(requirements))
File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py”, line 846, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The ‘Mopidy==2.1.0’ distribution was not found and is required by the application

I’ve spent all evening scratching my head over this and I’ve found a way to get it working. There are two problems with the instructions as of recently.

  1. Homebrew now defaults to python3, which does not work with Mopidy. Installing anything that depends on ‘python’ will pull in python3, which then breaks everything.
  2. Mopidy’s Homebrew formula for libspotify no longer works, as the binary download is no longer available on spotify’s developer site.

To fix this, I had to install all the binary dependencies from Homebrew, force Homebrew to use python2.7, and make sure I installed all the python stuff using pip. So, ignore all the instructions on the mopidy site and do this instead.

If you’ve already installed it, remove Homebrew first and make sure you then remove any /usr/local/lib/python* directories that are left behind.
Instructions for removing Homebrew : https://github.com/Homebrew/brew/blob/master/docs/FAQ.md#how-do-i-uninstall-homebrew

Install Homebrew.

Install python 2.7 from Homebrew

brew install python@2

Install Mopidy’s binary dependencies (gstreamer).

brew install gst-plugins-base --with-libogg --with-libvorbis --with-opus --with-theora
brew install gst-plugins-good --with-flac --with-libshout --with-speex --with-taglib
brew install gst-plugins-bad --with-faad2 --with-libmms
brew install gst-plugins-ugly --with-flac --with-lame --with-libmms --with-libvorbis --with-mad --with-libshout --with-theora --with-two-lame
brew install gst-libav

Install gstreamer python bindings, making sure to force it to use python 2.7, otherwise it’ll pull in python3. The order of the options seemed to make a difference, even though it shouldn’t.

brew install pygobject3 --with-python@2 --without-python
brew install gst-python --without-python --with-python@2

Now install mopidy from pip

pip install --upgrade pip
pip install mopidy mopidy-spotify

And you can now run mopidy by typing 'mopidy". It’s working for me now.

To get it to load at login, create a file

~/Library/LaunchAgents/my.hack.for.mopidy.plist

with the following content

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>my.hack.for.mopidy</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/mopidy</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

Then do

launchctl load ~/Library/LaunchAgents/my.hack.for.mopidy.plist

HTH.

1 Like

Just to add to this—I followed these instructions but did not remove python3 since I need it for other things. It seemed to work fine, and if you encounter an error you can always reinstall with the flag --with-python@2

@fatg3erman any way we can let homebrew know this is broken?

The homebrew mopidy tap is run by the mopidy guys so it’s up to them to fix it. I don’t think it’s going to be very fixable though, since Spotify have removed the Mac version of libspotify. It’d be better for the Mopidy guys to change the install instructions, probably.

I went through your process, no error messages, installed everything flawlessly. Where you say I can start mopidy by typing mopidy it still says: -bash: /usr/local/bin/mopidy: No such file or directory

I really think I followed your instructions to the letter. Any idea what went wrong?

Thank you!!!. this is the only instruction that works for me.

The brew installation instructions at https://docs.mopidy.com/en/latest/installation/osx/ were very recently updated (thanks @jcass77). If they do not work please let us know.

This worked great. I tried the updated instructions but even still, I believe the true fix was reinstalling these with the force of python2

brew install pygobject3 --with-python@2 --without-python
brew install gst-python --without-python --with-python@2

but I picked up from those steps and followed to the end (not a user of spotify so eliminated that) anyways.

Thank you!

This no longer works because the gst-python homebrew package has now removed support for python@2. See gst-python: remove Python 2 support. · Homebrew/homebrew-core@4ffd6c1 · GitHub

Confirmed. There’s no fix or this except to update Mopidy to support python3

This is referenced here, with a workaround