Python3.9.12+Alpine镜像:解决matplotlib构建wheel失败问题
在Alpine Docker镜像中安装Matplotlib的qhull下载失败问题解决
错误信息
error: Failed to download any of the following: ['http://www.qhull.org/download/qhull-2020-src-8.0.2.tgz']. Please download one of these urls and extract it into 'build/' at the top-level of the source repository. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for matplotlib Failed to build matplotlib ERROR: Could not build wheels for matplotlib, which is required to install pyproject.toml-based projects
解决方法
方法一:安装系统级qhull依赖
Alpine的软件源中提供了qhull的开发包,安装后matplotlib编译时会直接调用系统已有的qhull,无需自行下载:
apk add --no-cache qhull-dev pip install matplotlib
方法二:手动下载并指定qhull路径
如果系统包安装后仍有问题,可手动下载qhull源码并指定路径:
- 创建临时目录:
mkdir -p /tmp/matplotlib-build/build
- 下载qhull 2020.2版本的源码压缩包,解压到上述
build目录(确保解压后的文件直接在build目录内,不要嵌套子目录) - 设置环境变量后安装matplotlib:
export QHULL_DIR=/tmp/matplotlib-build pip install matplotlib
方法三:安装兼容的预编译版本
选择对Python3.9和Alpine兼容性更好的matplotlib版本,避免编译过程:
pip install matplotlib==3.5.3
内容的提问来源于stack exchange,提问作者Davood
相关产品推荐
相关产品推荐

