beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.91k stars 1.82k forks source link

Trying to import returns traceback error #1993

Closed thedevilisinthedetails closed 8 years ago

thedevilisinthedetails commented 8 years ago

Problem

Trying to import returns traceback error (beet imp -t "{albumFile}")

Running this command in verbose (-vv) mode:

$ beet -vv (... paste here ...)

Led to this problem:

 File "/usr/local/bin/beet", line 9, in <module>
    load_entry_point('beets==1.3.17', 'console_scripts', 'beet')()
  File "/Library/Python/2.7/site-packages/beets/ui/__init__.py", line 1236, in main
    _raw_main(args)
  File "/Library/Python/2.7/site-packages/beets/ui/__init__.py", line 1226, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/Library/Python/2.7/site-packages/beets/ui/commands.py", line 966, in import_func
    import_files(lib, paths, query)
  File "/Library/Python/2.7/site-packages/beets/ui/commands.py", line 943, in import_files
    session.run()
  File "/Library/Python/2.7/site-packages/beets/importer.py", line 321, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/Library/Python/2.7/site-packages/beets/util/pipeline.py", line 302, in run
    out = self.coro.send(msg)
  File "/Library/Python/2.7/site-packages/beets/util/pipeline.py", line 184, in coro
    func(*(args + (task,)))
  File "/Library/Python/2.7/site-packages/beets/importer.py", line 1265, in lookup_candidates
    task.lookup_candidates()
  File "/Library/Python/2.7/site-packages/beets/importer.py", line 592, in lookup_candidates
    autotag.tag_album(self.items, search_ids=self.search_ids)
  File "/Library/Python/2.7/site-packages/beets/autotag/match.py", line 439, in tag_album
    search_album, va_likely)
  File "/Library/Python/2.7/site-packages/beets/autotag/hooks.py", line 580, in album_candidates
    out.extend(plugins.candidates(items, artist, album, va_likely))
  File "/Library/Python/2.7/site-packages/beets/plugins.py", line 357, in candidates
    out.extend(plugin.candidates(items, artist, album, va_likely))
  File "/Library/Python/2.7/site-packages/beetsplug/discogs.py", line 147, in candidates
    return self.get_albums(query)
  File "/Library/Python/2.7/site-packages/beetsplug/discogs.py", line 207, in get_albums
    type='release').page(1)
  File "/Library/Python/2.7/site-packages/discogs_client/models.py", line 336, in page
    data = self.client._get(self._url_for_page(index))
  File "/Library/Python/2.7/site-packages/discogs_client/client.py", line 110, in _get
    return self._request('GET', url)
  File "/Library/Python/2.7/site-packages/discogs_client/client.py", line 97, in _request
    content, status_code = self._fetcher.fetch(self, method, url, data=data, headers=headers)
  File "/Library/Python/2.7/site-packages/discogs_client/fetchers.py", line 73, in fetch
    resp, content = self.oauth_client.request(url, method, headers=headers)
  File "/Library/Python/2.7/site-packages/oauth2/__init__.py", line 682, in request
    connection_type=connection_type)
  File "/Library/Python/2.7/site-packages/httplib2/__init__.py", line 1593, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
  File "/Library/Python/2.7/site-packages/httplib2/__init__.py", line 1388, in _request
    redirections=redirections - 1)
  File "/Library/Python/2.7/site-packages/oauth2/__init__.py", line 662, in request
    req.sign_request(self.method, self.consumer, self.token)
  File "/Library/Python/2.7/site-packages/oauth2/__init__.py", line 493, in sign_request
    self['oauth_body_hash'] = base64.b64encode(sha(self.body).digest())
TypeError: must be string or buffer, not None

Here's a link to the music files that trigger the bug (if relevant):

Setup

My configuration (output of beet config) is:

directory: /Users/peterkoondial/Music/Musique
library: /Users/peterkoondial/.config/beets/library.db
write: yes
copy: yes
move: true
original_date: true
per_disc_numbering: true
plugins: fetchart embedart lyrics inline discogs
paths:
    default: $albumartist/($year) $album%aunique{}/%if{$multidisc,Disc $disc}/$track - $title
    singleton: Non-Album/$artist/$title
    comp: Various Artist/($year) $album%aunique{}/%if{$multidisc,Disc$disc}/$track - $title
    albumtype: soundtrack:Soundtracks/album/$track $title
item_fields:
    multidisc: 1 if disctotal > 1 else 0
jackwilsdon commented 8 years ago

Do you think you could fill in the necessary sections of the issue? More specifically the beet config section, as it looks like it's related to your discogs token.

thedevilisinthedetails commented 8 years ago

sorry, updated.

thedevilisinthedetails commented 8 years ago

i have my discogs_token.json in my config file

jackwilsdon commented 8 years ago

Take a look at #1949, primarily #1949 (comment).

thedevilisinthedetails commented 8 years ago

Works but i get this error before the candidates appears

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/beets/plugins.py", line 255, in load_plugins
    namespace = __import__(modname, None, None)
  File "/Library/Python/2.7/site-packages/beetsplug/fetchart.py", line 26, in <module>
    import requests
ImportError: No module named requests

** error loading plugin lyrics:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/beets/plugins.py", line 255, in load_plugins
    namespace = __import__(modname, None, None)
  File "/Library/Python/2.7/site-packages/beetsplug/lyrics.py", line 23, in <module>
    import requests
ImportError: No module named requests

** error loading plugin discogs:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/beets/plugins.py", line 255, in load_plugins
    namespace = __import__(modname, None, None)
  File "/Library/Python/2.7/site-packages/beetsplug/discogs.py", line 28, in <module>
    from discogs_client import Release, Client
ImportError: No module named discogs_client
jackwilsdon commented 8 years ago

Take a look at #1949 (comment).

You'll want to run this to install all of the dependencies:

pip install -U beets[fetchart,discogs,import]
thedevilisinthedetails commented 8 years ago

did that now I'm getting

Traceback (most recent call last):
  File "/usr/local/bin/beet", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2793, in <module>
    working_set.require(__requires__)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 673, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 576, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: musicbrainzngs>=0.4

i try to update musicbrainzngs but i guess I'm already updated

jackwilsdon commented 8 years ago

Hmm, there is something weird going on with your system. I'm on OS X 10.11.4 and I can just install beets from scratch fine with pip install beets.

What's the output from pip install -U musicbrainzngs?

thedevilisinthedetails commented 8 years ago

I agree.

Requirement already up-to-date: musicbrainzngs in /usr/local/lib/python2.7/site-packages

jackwilsdon commented 8 years ago

Oh dear, it seems you're using python from OS X and pip from brew! That sounds like a right mess πŸ˜†.

Could you run these and provide the output?

which python
which pip
brew list
thedevilisinthedetails commented 8 years ago

ah can't recall when and why i would install brew on this machine. but seems you're right:

/Library/Frameworks/Python.framework/Versions/2.7/bin/python

/usr/local/bin/pip

gdbm openssl pkg-config python readline sqlite

jackwilsdon commented 8 years ago

Interesting how python is already installed via brew, yet your shell is still pulling it from /Library/Frameworks. Could you try this?

brew link python

And if that fails saying it is already linked, try this:

brew unlink python && brew link python

And finally re-run the commands from my previous comment.

thedevilisinthedetails commented 8 years ago

/Library/Frameworks/Python.framework/Versions/2.7/bin/python

/usr/local/bin/pip

gdbm openssl pkg-config python readline sqlite

jackwilsdon commented 8 years ago

Try this:

echo $PATH

It seems that the python for brew is not being added to your PATH.

thedevilisinthedetails commented 8 years ago

/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

jackwilsdon commented 8 years ago

That's very odd! Have you added the python framework to your PATH yourself? What are the contents of your .bashrc in your home folder?

thedevilisinthedetails commented 8 years ago

. not that i recall. I don't have that file bash file

jackwilsdon commented 8 years ago

Could you run this command in your home directory?

ls -d .[!.]*
thedevilisinthedetails commented 8 years ago

.CFUserTextEncoding .Trash .bash_profile .distlib .oracle_jre_usage .ssh .DS_Store .adobe .config .dropbox .pia_manager .viminfo .SoulseekQt .bash_history .cups .lyrics .pia_manager_crash.log

jackwilsdon commented 8 years ago

What are the contents of your .bash_profile? I suspect it contains a line adding the OS X python binaries to your PATH.

thedevilisinthedetails commented 8 years ago

yup, PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"

jackwilsdon commented 8 years ago

Just comment that line out by adding # to the start. Not entirely sure why it was there in the first place!

thedevilisinthedetails commented 8 years ago

done. should this actually use my default python on my OS X?

jackwilsdon commented 8 years ago

I'd say it's better to use the brew one, The Hitchhiker's Guide to Python puts it well:

The latest version of Mac OS X, El Capitan, comes with Python 2.7 out of the box.

You do not need to install or configure anything else to use Python. Having said that, I would strongly recommend that you install the tools and libraries described in the next section before you start building Python applications for real-world use.

...

The version of Python that ships with OS X is great for learning but it’s not good for development. The version shipped with OS X may be out of date from the official current Python release, which is considered the stable production version.

thedevilisinthedetails commented 8 years ago

k. so now i get this for which python.

/usr/local/bin/python

/usr/local/bin/pip

gdbm        openssl     pkg-config  python      readline    sqlite

tried to update musicbrainzngs and i still get the error

jackwilsdon commented 8 years ago

Try uninstalling it with pip uninstall musicbrainzngs and then reinstalling it.

May need @sampsyo on this one because I'm running out of ideas πŸ˜†.

thedevilisinthedetails commented 8 years ago

Did and same issue:

Traceback (most recent call last): File "/usr/local/bin/beet", line 5, in <module> from pkg_resources import load_entry_point File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2793, in <module> working_set.require(__requires__) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 673, in require needed = self.resolve(parse_requirements(requirements)) File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 576, in resolve raise DistributionNotFound(req) pkg_resources.DistributionNotFound: musicbrainzngs>=0.4

Thanks a ton for your help though, really appreciate it:). Guess will wait for @sampsyo to comment.

jackwilsdon commented 8 years ago

It's still using the wrong python! Have you closed and reopened your terminal?

thedevilisinthedetails commented 8 years ago

yup.

jackwilsdon commented 8 years ago

Very strange, what's the output of echo $PATH now?

thedevilisinthedetails commented 8 years ago

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

jackwilsdon commented 8 years ago

Well now I have no idea! Final possibility, uninstall beets completely and reinstall.

pip uninstall beets
pip install beets

For some reason it looks like /usr/local/bin/beet is pulling in the /System/Library/Frameworks/Python.framework/Versions/2.7 version of Python instead of the brew one located in /usr/local, crazy! Hoping reinstalling will set it straight.

thedevilisinthedetails commented 8 years ago

works! thanks so much for your troubles!!

jackwilsdon commented 8 years ago

Success! I'll close up this issue 😁.