当前位置:   article > 正文

Python3.8中安装matplotlib库报错问题的解决过程_error: cannot install metadata==0.1, metadata==0.1

error: cannot install metadata==0.1, metadata==0.1.1 and metadata==0.2 becau

1、用pip3安装numpy库:
liujiandeMacBook-Pro:bin ThomasLiu$ pip3 install numpy
Collecting numpy
Downloading https://files.pythonhosted.org/packages/9e/cf/7cea38d32df6087d7c15bca8edef0be82e0d957119e9dafd7052dc6192f0/numpy-1.17.4-cp38-cp38-macosx_10_9_x86_64.whl (15.1MB)
|████████████████████████████████| 15.1MB 495kB/s
Installing collected packages: numpy
Successfully installed numpy-1.17.4
WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.
liujiandeMacBook-Pro:bin ThomasLiu$ pwd
/Library/Frameworks/Python.framework/Versions/3.8/bin
liujiandeMacBook-Pro:bin ThomasLiu$ pip3 install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl (1.4MB)
|████████████████████████████████| 1.4MB 311kB/s
Installing collected packages: pip
Found existing installation: pip 19.2.3
Uninstalling pip-19.2.3:
Successfully uninstalled pip-19.2.3
Successfully installed pip-19.3.1
liujiandeMacBook-Pro:bin ThomasLiu$ pip3 install numpy
Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (1.17.4)
liujiandeMacBook-Pro:bin ThomasLiu$

2、安装matplotlib:
liujiandeMacBook-Pro:learnpy ThomasLiu$ pip3 install matplotlib
Collecting matplotlib
Downloading https://files.pythonhosted.org/packages/12/d1/7b12cd79c791348cb0c78ce6e7d16bd72992f13c9f1e8e43d2725a6d8adf/matplotlib-3.1.1.tar.gz (37.8MB)
|████████████████████████████████| 37.8MB 2.1MB/s
Collecting cycler>=0.10
Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting kiwisolver>=1.0.1
Downloading https://files.pythonhosted.org/packages/22/a7/8f7706e8c1e847b9816bbb2c4c341e2ae9568653f17956f839574ed62815/kiwisolver-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl (61kB)
|████████████████████████████████| 71kB 9.9MB/s
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1
Downloading https://files.pythonhosted.org/packages/c0/0c/fc2e007d9a992d997f04a80125b0f183da7fb554f1de701bbb70a8e7d479/pyparsing-2.4.5-py2.py3-none-any.whl (67kB)
|████████████████████████████████| 71kB 8.6MB/s
Collecting python-dateutil>=2.1
Downloading https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227kB)
|████████████████████████████████| 235kB 7.7MB/s
Requirement already satisfied: numpy>=1.11 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from matplotlib) (1.17.4)
Collecting six
Downloading https://files.pythonhosted.org/packages/65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from kiwisolver>=1.0.1->matplotlib) (41.2.0)
Installing collected packages: six, cycler, kiwisolver, pyparsing, python-dateutil, matplotlib
Running setup.py install for matplotlib … error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/private/var/folders/jl/csmdpd9d19q20v55gn1hx9yh0000gn/T/pip-install-3xuge1z8/matplotlib/setup.py’"’"’; file=’"’"’/private/var/folders/jl/csmdpd9d19q20v55gn1hx9yh0000gn/T/pip-install-3xuge1z8/matplotlib/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record /private/var/folders/jl/csmdpd9d19q20v55gn1hx9yh0000gn/T/pip-record-j874dt4y/install-record.txt --single-version-externally-managed --compile
cwd: /private/var/folders/jl/csmdpd9d19q20v55gn1hx9yh0000gn/T/pip-install-3xuge1z8/matplotlib/
Complete output (511 lines):

其中有关键报错:gcc: error: unable to locate xcodebuild, please make sure the path to the Xc

搜索后发现是说重装一下xcode,于是重装xcode;

3、重装xcode过程中,报“xcode下载显示磁盘空间不足”,搜索后发现是timemachine导致的问题,清理历史备份点即可:
liujiandeMacBook-Pro:/ ThomasLiu$ sudo tmutil listlocalsnapshots /
com.apple.TimeMachine.2019-08-21-162649 (dataless)
com.apple.TimeMachine.2019-08-22-172534 (dataless)
com.apple.TimeMachine.2019-11-18-090815
com.apple.TimeMachine.2019-11-18-110241
com.apple.TimeMachine.2019-11-18-121126
com.apple.TimeMachine.2019-11-18-140229
com.apple.TimeMachine.2019-11-18-152151
com.apple.TimeMachine.2019-11-18-161724
—逐个清理:
liujiandeMacBook-Pro:/ ThomasLiu$ tmutil deletelocalsnapshots 2019-11-18-152151
Deleted local snapshot '2019-11-18-152151’
。。。
然后,xcode重装成功

4、继续安装matplotlib,又碰到关键报错“src/checkdep_freetype2.c:1:10: fatal error: ‘ft2build.h’ file not found”,搜索后,发现需要安装freetype包,需要先装brew

5、安装brew:
按照网页上的指示,执行如下ruby命令:
liujiandeMacBook-Pro:learnpy ThomasLiu$ ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following existing directories will be made group writable:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man8
==> The following existing directories will have their owner set to ThomasLiu:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man8
==> The following existing directories will have their group set to admin:
/usr/local/bin
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man8
==> The following new directories will be created:
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/sbin
/usr/local/var
/usr/local/opt
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var/homebrew
/usr/local/var/homebrew/linked
/usr/local/Cellar
/usr/local/Caskroom
/usr/local/Homebrew
/usr/local/Frameworks
Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man8
Password:
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man8
==> /usr/bin/sudo /usr/sbin/chown ThomasLiu /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man8
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin /usr/local/share /usr/local/share/man /usr/local/share/man/man8
==> /usr/bin/sudo /bin/mkdir -p /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown ThomasLiu /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/sbin /usr/local/var /usr/local/opt /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var/homebrew /usr/local/var/homebrew/linked /usr/local/Cellar /usr/local/Caskroom /usr/local/Homebrew /usr/local/Frameworks
==> /usr/bin/sudo /bin/mkdir -p /Users/ThomasLiu/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/ThomasLiu/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown ThomasLiu /Users/ThomasLiu/Library/Caches/Homebrew
==> Downloading and installing Homebrew…
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (11/11), done.
Receiving objects: 4% (5980/128856), 2.84 MiB | 27.00 KiB/s

无奈公司网速慢如蜗牛,换手机热点也不行。。。。。。
次日一早7点多,在家里宽带上,一分钟以内搞定:
liujiandeMacBook-Pro:~ ThomasLiu$ /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
Press RETURN to continue or any other key to abort
==> Downloading and installing Homebrew…
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 128856 (delta 2), reused 1 (delta 0), pack-reused 128845
Receiving objects: 100% (128856/128856), 30.72 MiB | 1.45 MiB/s, done.
Resolving deltas: 100% (94557/94557), done.
From https://github.com/Homebrew/brew

  • [new branch] master -> origin/master
  • [new tag] 0.1 -> 0.1
  • [new tag] 0.2 -> 0.2
  • [new tag] 0.3 -> 0.3
  • [new tag] 0.4 -> 0.4
  • [new tag] 0.5 -> 0.5
  • [new tag] 0.6 -> 0.6
  • [new tag] 0.7 -> 0.7
  • 。。。。。。
  • [new tag] 2.1.6 -> 2.1.6
  • [new tag] 2.1.7 -> 2.1.7
  • [new tag] 2.1.8 -> 2.1.8
  • [new tag] 2.1.9 -> 2.1.9
    HEAD is now at d65ad9fe1 Merge pull request #6754 from Homebrew/dependabot/bundler/docs/html-proofer-3.14.1
    ==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3.mavericks.bottle.tar.gz
    ######################################################################## 100.0%
    ==> Pouring portable-ruby-2.6.3.mavericks.bottle.tar.gz
    ==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
    https://github.com/Homebrew/brew#donations
    ==> Tapping homebrew/core
    Cloning into ‘/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core’…
    remote: Enumerating objects: 5083, done.
    remote: Counting objects: 100% (5083/5083), done.
    remote: Compressing objects: 100% (4875/4875), done.
    remote: Total 5083 (delta 46), reused 383 (delta 11), pack-reused 0
    Receiving objects: 100% (5083/5083), 4.15 MiB | 2.38 MiB/s, done.
    Resolving deltas: 100% (46/46), done.
    Tapped 2 commands and 4864 formulae (5,125 files, 12.8MB).
    Already up-to-date.
    ==> Installation successful!
    ==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
    Read the analytics documentation (and how to opt-out) here:
    https://docs.brew.sh/Analytics
    ==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
    https://github.com/Homebrew/brew#donations
    ==> Next steps:
  • Run brew help to get started
  • Further documentation:
    https://docs.brew.sh

要点:访问国外的技术网站,最佳时间是在北京时间早上(6点-8点?)吧,其他时间段都慢的像蜗牛一样。

6、继续安装freetype
liujiandeMacBook-Pro:~ ThomasLiu$ which brew
/usr/local/bin/brew
liujiandeMacBook-Pro:~ ThomasLiu$ brew install freetype
==> Installing dependencies for freetype: libpng
==> Installing freetype dependency: libpng
==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.37.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/53/53bbd14cc27c86c16605e256e7646a1b5656c253abca084958c5d80a2961cb01?gda=exp=1574120615~hmac=999e762b2f1a6053f964918b56becf5130077
######################################################################## 100.0%
==> Pouring libpng-1.6.37.mojave.bottle.tar.gz
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/866181

推荐阅读
相关标签