无法在macOS Big Sur上安装Matplotlib

2024-04-28 22:48:46 发布

您现在位置:Python中文网/ 问答频道 /正文

自从我将MacOs升级到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是不可能的吗?哈哈哈=(


Tags: andthetonumpyyoupackageformatplotlib
2条回答

我做到了!!!我修好了

对于此错误:

  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

您的easy_install已过时。因此,只需执行以下命令更新安装工具即可:

pip install setuptools==51

然后

easy_install  version

确保easy_install的版本高于51

相关问题 更多 >