首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有命名为soundfile的模块

没有命名为soundfile的模块
EN

Stack Overflow用户
提问于 2017-08-16 16:32:11
回答 4查看 16K关注 0票数 2

每当我尝试导入soundfile时,都会出现以下错误

代码语言:javascript
复制
ImportError: No module named soundfile

我安装pysoundfile似乎没有问题:

代码语言:javascript
复制
$ 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

那么是什么导致了这个问题呢?

EN

回答 4

Stack Overflow用户

发布于 2017-08-16 16:52:48

检查它是否安装在测试环境中

示例方法

代码语言:javascript
复制
$ pip install virtualenv
$ python -m virtualenv venv
$ source venv/bin/activate
$ pip install pysoundfile
$ python
>>> import soundfile
票数 2
EN

Stack Overflow用户

发布于 2017-08-16 17:23:57

PySoundFile依赖于Python包CFFI和NumPy,以及系统库libsndfile。

要安装Python依赖项,我建议使用Python3的Anaconda发行版。

这将与预先安装的所有依赖项一起提供。要手动安装依赖项,可以使用conda包管理器,该管理器将使用conda install cffi numpy安装所有依赖项(conda也可以通过pip install conda独立于Anaconda获得)。

安装了CFFI和NumPy后,您可以使用pip install pysoundfile下载并安装最新版本的PySoundFile。在Windows和OS X上,这还将安装库libsndfile。在Linux上,您需要使用发行版的包管理器安装libsndfile,例如sudo apt-get install libsndfile1

票数 1
EN

Stack Overflow用户

发布于 2017-12-20 14:47:03

我也有同样的问题,我猜问题出在python版本上。当我尝试使用Python 3.5.2时

代码语言:javascript
复制
python3 file_name.py
ImportError: No module named 'soundfile'

相反,我在Python 2.7.12中尝试了同样的方法

代码语言:javascript
复制
python file_name.py

成功导入!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45708735

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档