本地部署阿里的 SenseVoice 时发现,依赖于 ffmpeg 这种非 python 包,pip 没办法直接管理,但我又不想系统层面全局装,这时候发现 conda 可以实现代码项目层级的依赖包隔离。
1 安装
1.1 Mac 上安装
brew install miniconda
conda --version
|
Windows 上安装
winget install miniconda3
conda --version
|
2 使用
2.1 创建 conda 环境
conda env create -f environment.yml
conda activate ai-env
|
阿里 SenseVoice 和 CosyVoice 的依赖环境配置如下
name: ai-env channels: - conda-forge - defaults dependencies: - python=3.12 - ffmpeg - pip - pip: - flask - gunicorn - python-magic - pydub - modelscope - funasr - torch - torchaudio
|
其中的channels
可以换成国内的 conda 镜像源:中科大、清华、阿里云
channels: - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ - https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
|
channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
|
channels: - https://mirrors.aliyun.com/anaconda/pkgs/main/ - https://mirrors.aliyun.com/anaconda/pkgs/free/ - https://mirrors.aliyun.com/anaconda/cloud/conda-forge/
|
2.2 新增 python 包
在 conda 环境激活状态下,使用 pip 安装 python 依赖包,可以配置国内镜像源:中科大、清华、阿里云
pip config set global.index-url https://pypi.mirrors.ustc.edu.cn/simple
pip config list
|
出现一下结果说明配置成功
global.index-url='https://pypi.mirrors.ustc.edu.cn/simple'
|
更新日志