0

我在 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,但它失败了,因为我没有它所包含的库(我认为)。有没有人得到这个?谢谢!

4

1 回答 1

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
于 2013-10-13T13:33:07.770 回答