macOS Big Sur 下安装numpy和pandas

Python是我最喜欢的一个脚本语言,主要原因就是各种库非常多,并且相当齐全,安装也是非常简单,最近系统升级到Big Sur之后,发现python也升级到了3.9版本,奈何我之前装的一堆扩展都没了,只好重新装,但是当我装到pandas库的时候,总是出现以下问题:

ERROR: Command errored out with exit status 1:
   command: /usr/local/opt/[email protected]/bin/python3.9 /usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/_b/vfbnss6x5_nf44njbbg911k00000gn/T/tmpq9pbdhcr
       cwd: /private/var/folders/_b/vfbnss6x5_nf44njbbg911k00000gn/T/pip-install-hyqkgsxw/pandas
  Complete output (23 lines):
  init_dgelsd failed init
  Traceback (most recent call last):
    File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
      main()
    File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/private/var/folders/_b/vfbnss6x5_nf44njbbg911k00000gn/T/pip-build-env-qz4qwc6o/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 149, in get_requires_for_build_wheel
      return self._get_build_requires(
    File "/private/var/folders/_b/vfbnss6x5_nf44njbbg911k00000gn/T/pip-build-env-qz4qwc6o/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 130, in _get_build_requires
      self.run_setup()
    File "/private/var/folders/_b/vfbnss6x5_nf44njbbg911k00000gn/T/pip-build-env-qz4qwc6o/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 253, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/private/var/folders/_b/vfbnss6x5_nf44njbbg911k00000gn/T/pip-build-env-qz4qwc6o/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 145, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 20, in <module>
      import numpy
    File "/private/var/folders/_b/vfbnss6x5_nf44njbbg911k00000gn/T/pip-build-env-qz4qwc6o/overlay/lib/python3.9/site-packages/numpy/__init__.py", line 286, in <module>
      raise RuntimeError(msg)
  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

  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/opt/[email protected]/bin/python3.9 /usr/local/lib/python3.9/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/_b/vfbnss6x5_nf44njbbg911k00000gn/T/tmpq9pbdhcr Check the logs for full command output.

这一堆乱七八糟的东西我也看不懂,问了Google之后,说是不能装新版本的Numpy,但是卸载降级之后还是不行,再问Google说是python3.9不行,这个卸载降级可以有点麻烦了。继续找解决方法,最后终于在Github上找到了如下的解决方法

$ python3 -m pip install --upgrade pip setuptools wheel
followed by
$ python3 -m pip install --force-reinstall numpy

这个方法简单靠谱,终于治好了我的python


本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可。

相关文章

发表新评论