简体   繁体   English

无法在python中导入audiolab

[英]Can't import audiolab in python

I installed audiolab from this source:我从这个来源安装了audiolab:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikits.audiolab http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikits.audiolab

Those are the only windows binaries for python 2.7 I was able to find.这些是我能找到的唯一适用于 python 2.7 的 Windows 二进制文件。

When I call from scikits import audiolab I get the following error:当我from scikits import audiolab调用时from scikits import audiolab以下错误:

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    from scikits import audiolab
  File "C:\Python27\lib\site-packages\scikits\audiolab\__init__.py", line 34, in <module>
    from pysndfile.matapi import *
  File "C:\Python27\lib\site-packages\scikits\audiolab\pysndfile\matapi.py", line 145, in <module>
    Format('wav', 'pcm16').file_format)
  File "_sndfile.pyx", line 170, in scikits.audiolab.pysndfile._sndfile.Format.__init__ (scikits\audiolab\pysndfile\_sndfile.c:1429)
NameError: _SNDFILE_FILE_FORMAT

Is there a way to fix it?有办法解决吗? If not what should I use for audio processing instead?如果不是,我应该使用什么来进行音频处理? (Audiolab seemed to be the best alternative among audiotools and pyaudio) (Audiolab 似乎是 audiotools 和 pyaudio 中最好的选择)

EDIT:编辑:

After replacing libsndfile-1.dll, I have this new error:替换 libsndfile-1.dll 后,出现这个新错误:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    from scikits import audiolab
  File "C:\Python27\lib\site-packages\scikits\audiolab\__init__.py", line 25, in <module>
    from pysndfile import formatinfo, sndfile
  File "C:\Python27\lib\site-packages\scikits\audiolab\pysndfile\__init__.py", line 1, in <module>
    from _sndfile import Sndfile, Format, available_file_formats, \
  File "numpy.pxd", line 30, in scikits.audiolab.pysndfile._sndfile (scikits\audiolab\pysndfile\_sndfile.c:9632)
ValueError: numpy.dtype does not appear to be the correct type object

Note: numpy is installed.注意:numpy 已安装。

As far as I can tell you need to install libsndfile-1.0.25 as is mentioned right where you downloaded the binary 据我所知,你需要安装libsndfile-1.0.25,就像下载二进制文件时所提到的那样

Scikits.audiolab is a package for audio file IO using numpy arrays. Scikits.audiolab是一个使用numpy数组的音频文件IO包。 Linked against libsndfile-1.0.25. 链接libsndfile-1.0.25。

You can download an installer from here . 您可以从此处下载安装程序。 You may need to reinstall the scikits.audiolab distribution after you install libsndfile (although honestly, I'm not sure). 安装scikits.audiolab后可能需要重新安装scikits.audiolab发行libsndfile (虽然老实说,我不确定)。

However, if this seems a lot of effort, it might be easier for you to install Python 2.6 and install audiolab from PyPi as scikits docs suggest. 但是,如果这似乎付出了很多努力,那么您可能更容易安装Python 2.6并从PyPi安装audiolab ,就像scikits docs所建议的那样。 The PyPi version of scikits.audiolab is statically linked to libsndfile so you will not need to install it on your own. PyPi的版本scikits.audiolab静态链接到libsndfile这样你就不会需要你自己安装。

I had the same problem on Mac OS. 我在Mac OS上遇到了同样的问题。 It's possible that you updated or installed a new version of python/numpy after you install audiolab. 安装audiolab后,您可能更新或安装了新版本的python / numpy。 What I did is uninstall scikits.audiolab and reinstall it again, which got rid of this error 我做的是卸载scikits.audiolab并重新安装它,摆脱了这个错误

I had the same problem on Ubuntu 10.04.4 LTS. 我在Ubuntu 10.04.4 LTS上遇到了同样的问题。 The reason was that the installed version of audiolab was for python2.5, but in the meantime with Ubuntu 10.04.4 LTS python was upgradee to version 2.6. 原因是audiolab的安装版本是针对python2.5的,但与此同时,Ubuntu 10.04.4 LTS python升级到2.6版本。 After a new install of audiolab (wich grabbed the correct version) all's working fine. 在新安装的audiolab(获取正确的版本)之后,一切正常。

您需要做的就是安装 libsndfile 也可以。

brew install libsndfile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM