python - 无法在 macOS Big Sur 上安装 Matplotlib

标签 python matplotlib terminal

自从我将 MacO 升级到 Big Sur 后,我的数据科学库出现了一些问题。我能够安装 numpy 和 pandas(尽管如 topic 所述,它花费了不寻常的时间)。但是无法安装 Matplotlib。
我已经尝试了三件事...
首先使用默认的 MacOs 嵌入 Phyton 3.8.2 。
重新安装了 numpy,升级了 pip,但是当我尝试安装 Matplotlib 时。我有以下错误:

    RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend. If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
RankWarning: Polyfit may be poorly conditioned
后来,我在stackoverflow上看到了一些关于类似问题的建议,一个建议使用自制软件,所以我通过brew安装了Python 3.9.0。但是,当我尝试安装 Matplotlib 时,在尝试安装 Pillow 时仍然出现一个巨大的错误:
(.......) The headers or library files could not be found for jpeg,a required dependency when compiling 
Pillow from source.Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
ERROR: Command errored out with exit status 1: /usr/local/opt/python@3.9/bin/python3.9 (...)
为了完成(几乎绝望),我尝试使用 venv(和 Python 3.8.2)创建一个虚拟环境并且能够成功安装 NumPy,但是,我在尝试安装 Matplotlib 时遇到以下错误:
(...... long line of code....) The package setup script has attempted to modify files on your system
that are not within the EasyInstall build area, and has been aborted.

This package cannot be safely installed by EasyInstall, and may not
support alternate installation locations even if you run its setup
script by hand.  Please inform the package's author and the EasyInstall
maintainers to find out if a fix or workaround is available.
真的不知道该怎么办......在BigSur上干净安装Matplotlib是不可能的吗?哈哈哈=(

最佳答案

我做到了!!!我修理它!!
对于这个错误:

  RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend.
 If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
 RankWarning: Polyfit may be poorly conditioned
我修复了安装较旧的 numpy 版本。
pip3 install --force-reinstall numpy\<1.19
它完成了任务。
对于第二个错误:
(.......) The headers or library files could not be found for jpeg,a required dependency when compiling 
Pillow from source.Please see the install instructions at: https://pillow.readthedocs.io/en/latest/installation.html
ERROR: Command errored out with exit status 1: /usr/local/opt/python@3.9/bin/python3.9 (...)
这是缺少的 JPEG 库。我确实建议你们安装自制软件。
解决了这个问题:
brew install libjpeg

关于python - 无法在 macOS Big Sur 上安装 Matplotlib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64884415/

相关文章:

python - Matplotlib说fig.canvas是None,所以我不能使用fig.canvas.draw

python - 在python中访问Ajax数据

pandas - pandas .p​​lot()x轴刻度频率—如何显示更多刻度?

linux - 从一个分支克隆三个其他分支

xcode - 如何使用atos手动符号化崩溃日志

java - 错误找不到或加载主类

python - web2py:多个表:有条件插入/更新/删除:从一种表单

python - 无法使用 Firefox 驱动程序打开网站

python - 如何使用 networkx 在图形中显示节点名称?

python - 如何调试 Matplotlib 中的散点图?