简体   繁体   English

没有名为 soundfile 的模块

[英]No module named soundfile

Whenever I try to import soundfile I get the error每当我尝试导入soundfile我都会收到错误消息

ImportError: No module named soundfile

I installed pysoundfile seemingly without trouble:我安装 pysoundfile 似乎没有问题:

$ sudo pip install pysoundfile
The directory '/Users/theonlygusti/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/theonlygusti/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pysoundfile
  Downloading PySoundFile-0.9.0.post1-py2.py3.cp26.cp27.cp32.cp33.cp34.cp35.cp36.pp27.pp32.pp33-none-macosx_10_5_x86_64.macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.whl (573kB)
    100% |████████████████████████████████| 573kB 430kB/s
Requirement already satisfied: cffi>=0.6 in /Library/Python/2.7/site-packages (from pysoundfile)
Requirement already satisfied: pycparser in /Library/Python/2.7/site-packages (from cffi>=0.6->pysoundfile)
Installing collected packages: pysoundfile
Successfully installed pysoundfile-0.9.0.post1

so what's causing this problem?那么是什么导致了这个问题?

Check if it is installed in a test environment检查是否安装在测试环境中

Example Ways示例方式

$ pip install virtualenv
$ python -m virtualenv venv
$ source venv/bin/activate
$ pip install pysoundfile
$ python
>>> import soundfile

PySoundFile depends on the Python packages CFFI and NumPy, and the system library libsndfile. PySoundFile 依赖于 Python 包 CFFI 和 NumPy,以及系统库 libsndfile。

To install the Python dependencies, I recommend using the Anaconda distribution of Python 3.要安装 Python 依赖项,我建议使用 Python 3 的 Anaconda 发行版。

This will come with all dependencies pre-installed.这将预装所有依赖项。 To install the dependencies manually, you can use the conda package manager, which will install all dependencies using conda install cffi numpy (conda is also available independently of Anaconda with pip install conda ).要手动安装依赖项,您可以使用 conda 包管理器,它将使用conda install cffi numpy安装所有依赖conda install cffi numpyconda install cffi numpy也可以通过pip install conda conda install cffi numpy独立于 Anaconda 使用)。

With CFFI and NumPy installed, you can use pip install pysoundfile to download and install the latest release of PySoundFile.安装 CFFI 和 NumPy 后,您可以使用pip install pysoundfile下载并安装最新版本的 PySoundFile。 On Windows and OS X, this will also install the library libsndfile.在 Windows 和 OS X 上,这也将安装库 libsndfile。 On Linux, you need to install libsndfile using your distribution's package manager, for example sudo apt-get install libsndfile1 .在 Linux 上,您需要使用发行版的包管理器安装 libsndfile,例如sudo apt-get install libsndfile1

I had the same problem, I guess the problem is with python versions.我遇到了同样的问题,我想问题出在 python 版本上。 When I tried with Python 3.5.2当我尝试使用Python 3.5.2 时

python3 file_name.py
ImportError: No module named 'soundfile'

Instead, I tried the same with Python 2.7.12相反,我用Python 2.7.12尝试了同样的方法

python file_name.py

It successfully imported it!它成功导入了它!

For Google Colab Research对于 Google Colab 研究

copy paste this复制粘贴这个

!pip install soundfile

& then import it &然后导入它

import soundfile

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

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