OSX上的pyspotify问题

时间:2013-08-05 04:25:51

标签: python spotify

我在Mac上乱搞pyspotify,我一直在阅读示例和文档。我下载了一个示例应用程序(来自pyspotify git repo的jukebox.py示例),当我从命令行运行它时,我得到以下内容:

    Traceback (most recent call last):
  File "jukebox.py", line 15, in <module>
    AudioSink = import_audio_sink()
  File "/Library/Python/2.7/site-packages/spotify/audiosink/__init__.py", line 45, in import_audio_sink
    raise ImportError, "\n".join(error_messages)
ImportError: Tried to use spotify.audiosink.alsa.AlsaSink as audio sink, but failed:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/spotify/audiosink/__init__.py", line 36, in import_audio_sink
    module = __import__(module, fromlist=[cls])
  File "/Library/Python/2.7/site-packages/spotify/audiosink/alsa.py", line 1, in <module>
    import alsaaudio
ImportError: No module named alsaaudio

Tried to use spotify.audiosink.oss.OssSink as audio sink, but failed:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/spotify/audiosink/__init__.py", line 36, in import_audio_sink
    module = __import__(module, fromlist=[cls])
  File "/Library/Python/2.7/site-packages/spotify/audiosink/oss.py", line 1, in <module>
    import ossaudiodev
ImportError: No module named ossaudiodev

Tried to use spotify.audiosink.portaudio.PortAudioSink as audio sink, but failed:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/spotify/audiosink/__init__.py", line 36, in import_audio_sink
    module = __import__(module, fromlist=[cls])
  File "/Library/Python/2.7/site-packages/spotify/audiosink/portaudio.py", line 1, in <module>
    import pyaudio
ImportError: No module named pyaudio

Tried to use spotify.audiosink.gstreamer.GstreamerSink as audio sink, but failed:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/spotify/audiosink/__init__.py", line 36, in import_audio_sink
    module = __import__(module, fromlist=[cls])
  File "/Library/Python/2.7/site-packages/spotify/audiosink/gstreamer.py", line 3, in <module>
    import gobject
ImportError: No module named gobject

Was not able to import any of the audio sinks

我知道各种音频API /源的python包装器不存在,但我怎么知道我是否需要/如何安装gobject或pyaudio及其支持API?我试过pyaudio,但它失败了,因为我没有它包装的库(我认为)。有没有人以前得到过这个?谢谢!

1 个答案:

答案 0 :(得分:0)

这适用于master分支jukebox.py(截至2013-04-13 7eb1c53

brew install portaudio

pip install pyaudio

python -c "import pyaudio"

然后:

python example-jukebox-master.py -u myuser -p mypassword
Logging in, please wait...
Logged in!
jukebox> help

Documented commands (type help <topic>):
========================================
list  ls

Undocumented commands:
======================
EOF               browse  next   queue            search  toplist
add_new_playlist  help    pause  quit             shell   unwatch
add_to_playlist   logout  play   remove_playlist  stop    watch

> help ls
 List the playlists, or the contents of a playlist

这是从目前的发展:

python example-jukebox.py -u myuser -p mypassword -a portaudio