Python3.12.1虚拟环境安装ibm_watson_machine_learning失败:Pandas Wheel构建错误
解决Python 3.12.1虚拟环境安装ibm_watson_machine_learning的pandas编译错误
问题还原
在Python 3.12.1的全新虚拟环境中执行以下操作后:
py -m venv venv .\venv\scripts\activate pip install pandas pip install ibm_watson_machine_learning
出现错误:could not build wheels for pandas, which is required to install pyproject.toml-based projects
解决步骤
升级pip、setuptools和wheel
旧版工具链对pyproject.toml项目的支持不完善,先更新核心工具:pip install --upgrade pip setuptools wheel安装适配Python 3.12的pandas版本
部分旧版pandas未适配Python 3.12,需指定兼容版本(2.1.4及以上版本支持3.12):pip install pandas>=2.1.4补充Windows编译依赖
若在Windows环境,本地编译pandas需要Visual C++编译组件:- 下载安装微软Visual C++ Build Tools,勾选「Desktop development with C++」组件
- 重启终端后重新激活虚拟环境,再执行安装命令
安装最新版ibm_watson_machine_learning
旧版依赖包可能绑定了低版本pandas,尝试安装最新版:pip install ibm-watson-machine-learning --upgrade降级Python版本(终极方案)
若以上方法无效,暂时切换到Python 3.11.x版本创建虚拟环境,该版本对数据科学包兼容性更成熟:py -3.11 -m venv venv_311 .\venv_311\scripts\activate pip install ibm-watson-machine-learning
内容的提问来源于stack exchange,提问作者Hershel
相关产品推荐
相关产品推荐

