【问题标题】:Problem with installation of matplotlib in Python [duplicate]在 Python 中安装 matplotlib 的问题 [重复]
【发布时间】:2021-01-24 20:13:08
【问题描述】:

我正在尝试使用 python 3.9 在 windows x64 中安装 matplotlib。 当我这样做时:

pip 安装 matplotlib

我收到此错误:

ERROR: Command errored out with exit status 1:
 command: 'c:\program files\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Luca\\AppData\\Local\\Temp\\pip-install-zlfu5f08\\kiwisolver\\setup.py'"'"'; __file__='"'"'C:\\Users\\Luca\\AppData\\Local\\Temp\\pip-install-zlfu5f08\\kiwisolver\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Luca\AppData\Local\Temp\pip-pip-egg-info-mriih1bh'
     cwd: C:\Users\Luca\AppData\Local\Temp\pip-install-zlfu5f08\kiwisolver\
Complete output (44 lines):
WARNING: The wheel package is not available.
  ERROR: Command errored out with exit status 1:
   command: 'c:\program files\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Luca\\AppData\\Local\\Temp\\pip-wheel-pvxhkv11\\cppy\\setup.py'"'"'; __file__='"'"'C:\\Users\\Luca\\AppData\\Local\\Temp\\pip-wheel-pvxhkv11\\cppy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Luca\AppData\Local\Temp\pip-wheel-1s8s6o5r'
       cwd: C:\Users\Luca\AppData\Local\Temp\pip-wheel-pvxhkv11\cppy\
  Complete output (6 lines):
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for cppy
ERROR: Failed to build one or more wheels
Traceback (most recent call last):
  File "c:\program files\python39\lib\site-packages\setuptools\installer.py", line 128, in fetch_build_egg
    subprocess.check_call(cmd)
  File "c:\program files\python39\lib\subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['c:\\program files\\python39\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\Luca\\AppData\\Local\\Temp\\tmpggz7lusd', '--quiet', 'cppy>=1.1.0']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Luca\AppData\Local\Temp\pip-install-zlfu5f08\kiwisolver\setup.py", line 59, in <module>
    setup(
  File "c:\program files\python39\lib\site-packages\setuptools\__init__.py", line 164, in setup
    _install_setup_requires(attrs)
  File "c:\program files\python39\lib\site-packages\setuptools\__init__.py", line 159, in _install_setup_requires
    dist.fetch_build_eggs(dist.setup_requires)
  File "c:\program files\python39\lib\site-packages\setuptools\dist.py", line 699, in fetch_build_eggs
    resolved_dists = pkg_resources.working_set.resolve(
  File "c:\program files\python39\lib\site-packages\pkg_resources\__init__.py", line 779, in resolve
    dist = best[req.key] = env.best_match(
  File "c:\program files\python39\lib\site-packages\pkg_resources\__init__.py", line 1064, in best_match
    return self.obtain(req, installer)
  File "c:\program files\python39\lib\site-packages\pkg_resources\__init__.py", line 1076, in obtain
    return installer(requirement)
  File "c:\program files\python39\lib\site-packages\setuptools\dist.py", line 758, in fetch_build_egg
    return fetch_build_egg(self, req)
  File "c:\program files\python39\lib\site-packages\setuptools\installer.py", line 130, in fetch_build_egg
    raise DistutilsError(str(e)) from e
distutils.errors.DistutilsError: Command '['c:\\program files\\python39\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\Luca\\AppData\\Local\\Temp\\tmpggz7lusd', '--quiet', 'cppy>=1.1.0']' returned non-zero exit status 1.
----------------------------------------ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

我尝试遵循我在此处找到的所有建议,但它继续产生错误。

谁能帮帮我?

【问题讨论】:

    标签: python matplotlib setup.py


    【解决方案1】:

    从堆栈跟踪看来好像没有安装轮子

    试试下面的

    pip install wheel

    然后运行

    python setup.py bdist_wheel

    根据文档PIP Wheel

    Build System Interface¶
    In order for pip to build a wheel, setup.py 
    must implement the bdist_wheel command with the following syntax:
    
    python setup.py bdist_wheel -d TARGET
    This command must create a wheel compatible with the 
    invoking Python interpreter, and save that wheel in the 
    directory TARGET.
    
    No other build system commands are invoked by the pip wheel command.
    

    【讨论】:

    • 当我运行第二条指令时,错误是:python: can't open file 'C:\WINDOWS\system32\setup.py': [Errno 2] No such file or directory
    • 当我运行 python setup.py bdist_wheel 时,错误是: python: can't open file 'C:\WINDOWS\system32\setup.py': [Errno 2] No such file or directory
    【解决方案2】:

    试试

    pip install wheel 
    

    然后再试一次。

    【讨论】:

    【解决方案3】:

    你应该在安装轮子后再次运行“pip install matplotlib”。

    在我的情况下,错误转向枕头安装,我成功安装枕头后,我终于可以安装matplotlib了!

    【讨论】:

    【解决方案4】:

    我有同样的错误。运行pip install wheel 后,我使用--prefer-binary 标志运行安装:

    python -m pip install -U matplotlib --prefer-binary.

    文档内容如下:

    如果此命令导致从源代码编译 Matplotlib 并且编译出现问题,您可以添加 --prefer-binary 以选择最新版本的 Matplotlib,该版本有适用于您的 OS 和 Python 的预编译轮。

    【讨论】:

      猜你喜欢
      • 2014-03-14
      • 1970-01-01
      • 1970-01-01
      • 2021-11-29
      • 2021-02-17
      • 1970-01-01
      • 2011-01-28
      • 2020-08-09
      • 1970-01-01
      相关资源
      最近更新 更多