[英]Can't import soundfile python
while using import soundfile
on wither python3 or python I am getting:在使用
import soundfile
soundfile on wither python3 或 python 时,我得到:
Traceback (most recent call last): File "", line 1, in File "/home/erezsh/.local/lib/python3.6/site-packages/soundfile.py", line 142, in raise OSError('sndfile library not found') OSError: sndfile library not found
回溯(最近调用最后一次):文件“”,第 1 行,在文件“/home/erezsh/.local/lib/python3.6/site-packages/soundfile.py”,第 142 行,在 raise OSError('sndfile找不到库') OSError: 找不到 sndfile 库
I found this post which did not help because I am using soundfile
and not pysoundfile
and the link it offers is broken.我发现这篇文章没有帮助,因为我使用的是
soundfile
而不是pysoundfile
并且它提供的链接已损坏。
Also, here I could not find a solution since I have installed using pip install SoundFile
.另外,在这里我找不到解决方案,因为我已经使用
pip install SoundFile
。
I am using Ubuntu shell on windows. Is this of any importance?我在 windows 上使用 Ubuntu shell。这重要吗?
How do I solve this?我该如何解决这个问题?
handras 答案(从 2019 年开始)现在(2020 年)不起作用,因此通过( 作为 AB )安装 libsndfile1
sudo apt-get install libsndfile1-dev
Try using the conda installation is you do not have sudo priviliges.如果您没有 sudo 权限,请尝试使用 conda 安装。
It worked for me, while I continued to face issues via the pip installation.它对我有用,而我通过 pip 安装继续面临问题。
conda install -c conda-forge librosa
The above command installs librosa.上面的命令安装 librosa。 You might be able to find a specific one for only soundfile too.
您也可以为声音文件找到特定的文件。
UPDATE: Needed to run apt update
first, and it worked.更新:需要先运行
apt update
,它才起作用。
The accepted answer at first did not work for me.起初接受的答案对我不起作用。
I'm inside a docker image:我在一个泊坞窗图像中:
apt-get install libsndfile1
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libsndfile1
in case of yum package manager users first install the dependency如果是 yum package manager 用户首先安装依赖项
sudo yum -y install libsndfile
afterwards run the pip installs之后运行 pip 安装
pip install SoundFile
pip install librosa
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.