Question

I have a problem in my attempt to make my first spotify app. I'm on a raspberry pi, running Arch.

I have my __main__.py and my spotify_appkey.key in a directory and i run it by [root@RPI]# python2 __main__.py

The code in __main__.py looks like this:

import spotify
print "1"
session = spotify.Session()
print "2"
try:
    session.login('myUsername', 'myPassword')
    print "3"
except IOError as e:
    print "error({0}): {1}".format(e.errno, e.strerror)

This gives me this output:

1
2
Segmentation fault (core dumped)

Reading on this link, I've tried this as well:

import spotify
print "1"
session = spotify.Session()
print "2"
config = spotify.Config()
print "3"
try:
    session.login('myUsername', 'myPassword')
    print "4"
except IOError as e:
    print "error({0}): {1}".format(e.errno, e.strerror)

which gives me this:

1
2
Traceback ..... yada yada ...
    File "__main__.py" ... yada yada...
        config = spotify.Config()
AttributeError: 'module' object has no attribute 'Config'

What am I doing wrong?

Was it helpful?

Solution

Author of pyspotify here :-)

dano is right: It seems like you're reading the v2.x docs and using v1.x. v2.x is a full rewrite with different and hopefully a lot simpler APIs to work with, so it's imperative that you use the docs that matches the version you code against:

At this point, I'd recommend using v2.x for all new applications. The v2.x API is easier to work with, works on more Python versions, covers the full libspotify API, and is actively maintained. The first beta, v2.0.0b1, was released yesterday. The final v2.0.0 release is hopefully just a few weeks away.

If you want to run pyspotify v2.x on Arch right away, you can install libspotify using yaourt:

sudo yaourt -S libspotify

Install the pyspotify build dependencies using pacman:

sudo pacman -S base-devel

And then install the latest pyspotify beta release using pip (either in a virtualenv or using sudo):

pip install --pre pyspotify

The --pre flag is required until pyspotify 2.0.0 final is released.

For more details, see http://pyspotify.mopidy.com/en/latest/installation/.

pyspotify v2.x will probably appear in AUR shortly after final release.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top