[英]scikits.audiolab on Ubuntu Oneiric - ImportError: No module named _sndfile
Okay, so I wanted to do some basic signal processing in Python and found this great library called scikits.audiolab
. 好的,所以我想在Python中做一些基本的信号处理,发现这个名为
scikits.audiolab
好库。
No PPA anywhere to be found. 没有任何PPA可以找到。 Oh well.
那好吧。 I thought I could install it on my Ubuntu Oneiric server by simply
我以为我可以简单地在我的Ubuntu Oneiric服务器上安装它
sudo aptitude install libsndfile-dev
and then 然后
sudo easy_install scikits.audiolab
This, however, failed with 然而,这失败了
error: sndfile (http://www.mega-nerd.com/libsndfile/) library not found.
Directories to search for the libraries can be specified in the
site.cfg file, in section [sndfile].
Wtf? 跆拳道? Okay, queried the
libsndfile1-dev
file list: 好的,查询了
libsndfile1-dev
文件列表:
japsu@helios ~ $ apt-file list libsndfile1-dev
libsndfile1-dev: /usr/include/sndfile.h
libsndfile1-dev: /usr/include/sndfile.hh
libsndfile1-dev: /usr/lib/x86_64-linux-gnu/libsndfile.a
libsndfile1-dev: /usr/lib/x86_64-linux-gnu/libsndfile.la
libsndfile1-dev: /usr/lib/x86_64-linux-gnu/libsndfile.so
libsndfile1-dev: /usr/lib/x86_64-linux-gnu/pkgconfig/sndfile.pc
[...]
Weird, libraries going into non-standard library directory? 很奇怪,图书馆进入非标准库目录? Stupid packager.
愚蠢的打包者。
Oh well. 那好吧。 Downloaded the source for
scikits.audiolab
, wrote a site.cfg
like this: 下载了
scikits.audiolab
的源scikits.audiolab
,写了一个这样的site.cfg
:
[sndfile]
include_dirs = /usr/include
library_dirs = /usr/lib/x86_64-linux-gnu/
sndfile_libs = sndfile
Now python setup.py build
and sudo setup.py install
completed successfully. 现在
python setup.py build
和sudo setup.py install
成功完成。
Next, fired up a Python shell, tried to from scikits.audiolab import sndfile
: 接下来,启动了一个Python shell,试图
from scikits.audiolab import sndfile
:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "scikits/audiolab/__init__.py", line 25, in <module>
from pysndfile import formatinfo, sndfile
File "scikits/audiolab/pysndfile/__init__.py", line 1, in <module>
from _sndfile import Sndfile, Format, available_file_formats, \
ImportError: No module named _sndfile
But: 但:
>> sys.path
['',
'/usr/bin',
'/usr/lib/pymodules/python2.7',
'/usr/local/lib/python2.7/dist-packages/scikits.audiolab-0.11.0-py2.7-linux-x86_64.egg',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/IPython/Extensions',
u'/home/japsu/.ipython']
And _sndfile.so
found at /usr/local/lib/python2.7/dist-packages/scikits.audiolab-0.11.0-py2.7-linux-x86_64.egg/scikits/audiolab/pysndfile/_sndfile.so
. 并且
_sndfile.so
位于/usr/local/lib/python2.7/dist-packages/scikits.audiolab-0.11.0-py2.7-linux-x86_64.egg/scikits/audiolab/pysndfile/_sndfile.so
。
So, my question is, 所以,我的问题是,
_sndfile.so
? _sndfile.so
? scikits.audiolab
in 2011 on a 2011 Linux distro? scikits.audiolab
? How did you do it? Someone suggested I check ldd _sndfile.so
. 有人建议我检查
ldd _sndfile.so
。 Did just that and got 做到了那就得到了
linux-vdso.so.1 => (0x00007fffd3dea000)
libsndfile.so.1 => /usr/lib/x86_64-linux-gnu/libsndfile.so.1 (0x00007f2bfbb5b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2bfb93e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2bfb59e000)
libFLAC.so.8 => /usr/lib/x86_64-linux-gnu/libFLAC.so.8 (0x00007f2bfb354000)
libvorbisenc.so.2 => /usr/lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007f2bfae85000)
libvorbis.so.0 => /usr/lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007f2bfac58000)
libogg.so.0 => /usr/lib/x86_64-linux-gnu/libogg.so.0 (0x00007f2bfaa51000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2bfa7cd000)
Interesting! 有趣! A bunch of file format libraries are also referenced, ones that I probably do not have installed.
还引用了一堆文件格式库,我可能还没有安装它们。
Did sudo aptitude install flac vorbis-tools
and voila! sudo aptitude install flac vorbis-tools
和瞧!
In [1]: from scikits.audiolab import sndfile
/usr/local/lib/python2.7/dist-packages/scikits.audiolab-0.11.0-py2.7-linux-x86_6
4.egg/scikits/audiolab/soundio/play.py:48: UserWarning: Could not import alsa ba
ckend; most probably, you did not have alsa headers when building audiolab
warnings.warn("Could not import alsa backend; most probably, "
I can probably ignore that warning about missing ALSA support for now as it's probably used for local recording and playback - and this is a server anyway. 我现在可能忽略了关于缺少ALSA支持的警告,因为它可能用于本地录制和播放 - 无论如何这都是服务器。
It would have been a whole lot easier if the lack of libFLAC
, libvorbis
and libvorbisenc
had triggered a build-time failure in the build scripts of scikits.audiolab
... After all, the final error message mentions nothing of those libraries. 如果没有
libFLAC
, libvorbis
和libvorbisenc
在libvorbisenc
的构建脚本中触发构建时失败,那scikits.audiolab
......毕竟,最后的错误消息没有提及这些库。
I you don't want to have the warning about alsa headers, just install the lib. 我不想有关于alsa头的警告,只需安装lib。
sudo apt-get install libasound2-dev sudo apt-get install libasound2-dev
That worked for me.. 这对我有用..
Edit: I just realized this is not the case as pysndfile seems to be bundled... I shouldn't be answering stuff the first thing in the morning ;) 编辑:我刚刚意识到这不是这种情况,因为pysndfile似乎被捆绑了...我不应该在早上回答第一件事;)
Answer to 1: Sndfile is ac library, you most probably need to install the python wrapper for it: http://code.google.com/p/libsndfile-python/ 回答1:Sndfile是ac库,你很可能需要为它安装python包装器: http : //code.google.com/p/libsndfile-python/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.