在Python中安装QuantLib库失败的问题求助
解决PyCharm中安装QuantLib库的版本匹配问题
问题描述
尝试在PyCharm中安装QuantLib库时遇到以下错误:
ERROR: Could not find a version that satisfies the requirement QuantLib (from versions: none) ERROR: No matching distribution found for QuantLib [notice] A new release of pip available: 22.3.1 -> 23.1 [notice] To update, run: pip install --upgrade pip
已升级pip但问题未解决,使用Python 3.7.16,尝试安装PyPI上的QuantLib-Python库(版本1.18)时,仍出现依赖错误:
Collecting QuantLib-Python==1.18 Using cached QuantLib_Python-1.18-py2.py3-none-any.whl (1.4 kB) ERROR: Could not find a version that satisfies the requirement QuantLib (from quantlib-python) (from versions: none) ERROR: No matching distribution found for QuantLib [notice] A new release of pip available: 22.3.1 -> 23.1 [notice] To update, run: pip install --upgrade pip
解决方案
指定兼容版本安装:Python 3.7的预编译QuantLib包在PyPI上仅保留部分旧版本,尝试安装适配的版本,比如:
pip install QuantLib==1.27这个版本是最后一批支持Python 3.7的预编译包之一。
从源码编译安装:如果没有合适的预编译包,直接编译源码:
- 安装C++编译器(如Visual Studio、GCC)和CMake工具
- 下载QuantLib核心库源码并编译安装
- 安装QuantLib-Python绑定:
或从QuantLib-Python源码编译安装。pip install QuantLib-Python
升级Python版本:切换到Python 3.8及以上版本,PyPI上提供对应版本的预编译QuantLib包,直接执行:
pip install QuantLib即可完成安装。
使用conda安装:若使用conda环境,通过conda-forge源安装,自动处理依赖和版本匹配:
conda install -c conda-forge quantlib-python
内容的提问来源于stack exchange,提问作者Devarshi Goswami
相关产品推荐
相关产品推荐

