IPython Essentia“未命名模块”

2024-04-28 05:59:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试使用一个Python模块,名为Essentia,用于音频分析。为了使用它,它必须按照here的说明在Ubuntu环境中构建。我把Essentia安装到桌面的一个文件夹中。在

然后在IPython中,我尝试导入已安装并构建的Essentia模块。我正在模块所在的文件夹中运行IPython。它不在/usr/lib/python2.7中。它位于我的桌面,如上所述。在

但当我在IPython中导入Essentia模块时,它告诉我

ImportError: No module named essentia

这里有什么问题?我是否必须在/usr/lib/python2.7内构建Essentia,如果是,我该怎么做?或者是其他事情出了问题?在


Tags: 模块no文件夹here环境ubuntulibusr
2条回答

我也遇到了同样的问题,并且能够解决它。在

从你的问题来看,我不能百分之百地确定你的问题是什么——然而,这是你或其他人可能有的几个罪魁祸首。在

我也在使用python2.7,并希望在IPython/Jupyter笔记本环境中使用Essentia。在

1。Essentia位置

这是我对你的问题的第一个猜测。

如果您能够成功地配置和安装Essentia(否则请参见下文),那么安装Essentia Python文件的路径可能是/usr/local/lib/python2.7/site-packages或类似的路径,而Python并不在那里。你一定要加上

import sys
sys.path.append("/usr/local/lib/python2.7/site-packages")

到Python脚本的开头。在

这帮我解决了这个问题

您还可以将以下行添加到~/.bash_profile

^{pr2}$

为了避免将此路径添加到您希望使用Essentia的每个Python文件/笔记本中。在

2。配置和安装

如果您能够成功配置和安装Essentia,请跳过此步骤。在我最终得到install finished successfully消息之前,我还有其他值得注意的问题。

如OP所述,主要指令是here。在

未找到ffftw3f或taglib

我用MacPorts解决了这个问题:

sudo port install fftw-3-single
sudo port install taglib

安装失败

我应该注意到,在安装过程中,我有一些问题,通过移除这些和其他一些来自配置行(as this has helped other users in the past):

,使我摆脱了C++测试、GAIa和VAMP插件支持(我不需要这些)。
./waf configure  mode=release  with-python  with-examples

而不是

./waf configure  mode=release  build-static  with-python  with-cpptests  with-examples  with-vamp  with-gaia

这使以下错误消息消失:

Build failed
 -> task in 'standard_fadedetection' failed (exit status 1): 
    {task 4417706448: cxxprogram standard_fadedetection.cpp.5.o -> standard_fadedetection}
['clang++', '-stdlib=libc++', 'src/examples/standard_fadedetection.cpp.5.o', '-o', '/Users/Brecht/Downloads/essentia-2.0.1/build/src/examples/standard_fadedetection', '-Lsrc', '-lessentia', '-L/opt/local/lib', '-L/opt/local/lib', '-L/opt/local/lib', '-L/opt/local/lib', '-L/opt/local/lib', '-L/opt/local/lib', '-L/opt/local/lib', '-L/opt/local/lib', '-lfftw3f', '-lyaml', '-lavformat', '-lavcodec', '-lavutil', '-lswresample', '-lsamplerate', '-ltag']
 -> task in 'streaming_extractor_freesound' failed (exit status 1): 
    {task 4417783952: cxxprogram FreesoundExtractor.cpp.22.o,FreesoundLowlevelDescriptors.cpp.22.o,FreesoundRhythmDescriptors.cpp.22.o,FreesoundSfxDescriptors.cpp.22.o,FreesoundTonalDescriptors.cpp.22.o,streaming_extractor_freesound.cpp.22.o -> streaming_extractor_freesound}
['clang++', '-stdlib=libc++', 'src/examples/freesound/FreesoundExtractor.cpp.22.o', 'src/examples/freesound/FreesoundLowlevelDescriptors.cpp.22.o', 'src/examples/freesound/FreesoundRhythmDescriptors.cpp.22.o', 'src/examples/freesound/FreesoundSfxDescriptors.cpp.22.o', 'src/examples/freesound/FreesoundTonalDescriptors.cpp.22.o', 'src/examples/streaming_extractor_freesound.cpp.22.o', '-o', '/Users/Brecht/Downloads/essentia-2.0.1/build/src/examples/streaming_extractor_freesound', '-Lsrc', '-lessentia', '-L/opt/local/lib', '-L/opt/local/lib', '-L/opt/local/lib', '-L/opt/local/lib', '-L/opt/local/lib', '-L/opt/local/lib', '-L/opt/local/lib', '-L/opt/local/lib', '-lfftw3f', '-lyaml', '-lavformat', '-lavcodec', '-lavutil', '-lswresample', '-lsamplerate', '-ltag']

让我知道这是怎么回事-我有一种感觉,我对你可能遇到的所有错误都已经有了感觉。在

确认:我之所以能这么快解决这个问题的主要原因是this thread-这也要归功于@djmoffat和{a5}。

我在macos10.14.5上安装时遇到了一些困难

为我解决了这个问题:

  • 用conda,pythonv3.7创建了一个虚拟环境
  • 安装了带有自制软件的essentia:brew install essentia HEAD

之后,我查找了Homebrew将站点包放在何处,并使用此代码在Jupyter笔记本中导入并使用essentia:

import sys
sys.path.append("/usr/local/homebrew/lib/python3.7/site-packages")

import essentia

相关问题 更多 >