要将Essentia音频包从Homebrew链接到Anaconda虚拟环境(venv)以便在Jupyter中使用,可以按照以下步骤操作:
首先,确保你已经通过Homebrew安装了Essentia。如果还没有安装,可以使用以下命令:
bashbrew install essentia
如果你还没有创建一个Anaconda虚拟环境,可以创建一个新的环境(例如,命名为essentia_env
):
bashconda create -n essentia_env python=3.9
激活该环境:
bashconda activate essentia_env
确保在你的虚拟环境中安装了编译器和开发工具,这对于链接Homebrew安装的库非常重要:
bashconda install -c anaconda setuptools
conda install -c conda-forge cmake
Essentia提供了Python绑定,可以通过pip
安装。但是,为了确保它链接到Homebrew安装的Essentia库,建议使用pip
从源码安装。
首先,安装必要的Python包:
bashpip install numpy scipy
然后,从源码安装Essentia的Python绑定:
bashpip install essentia-python
如果上述命令无法找到essentia-python
,你可能需要从源码编译安装。首先克隆Essentia的仓库:
bashgit clone https://github.com/MTG/essentia.git
cd essentia
然后,编译并安装:
bashmkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
make -j4
make install
确保在你的虚拟环境中安装了Jupyter:
bashconda install jupyter
为了让Jupyter识别你的虚拟环境,需要添加一个新的内核:
bashpython -m ipykernel install --user --name essentia_env --display-name "Python (Essentia)"
现在,你可以启动Jupyter Notebook并选择刚刚创建的内核:
bashjupyter notebook
在Jupyter Notebook中,选择“Python (Essentia)”内核,这样你就可以在Notebook中使用Essentia库了。
LD_LIBRARY_PATH
(Linux)或DYLD_LIBRARY_PATH
(macOS)环境变量,指向Homebrew安装Essentia库的路径。例如,在macOS上,可以在启动Jupyter Notebook之前设置环境变量:
bashexport DYLD_LIBRARY_PATH=$(brew --prefix essentia)/lib:$DYLD_LIBRARY_PATH
jupyter notebook
通过这些步骤,你应该能够在Anaconda虚拟环境中成功使用Essentia库,并在Jupyter Notebook中进行音频分析。
没有搜到相关的文章