PIP error : cannot build wheels for sip, which is required to install pyproject.toml-based projects

PIP error : cannot build wheels for sip, which is required to install pyproject.toml-based projects

每当我尝试使用 pip 安装 sip 时,它都会显示错误。完整的输出是:

Defaulting to user installation because normal site-packages is not writeable
Collecting sip
  Using cached sip-6.5.0.tar.gz (1.2 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: toml in c:\users\Admin\appdata\roaming\python\pyt
hon310-32\site-packages (from sip) (0.10.2)
Requirement already satisfied: setuptools in c:\program files\python310-32\lib\s
ite-packages (from sip) (57.4.0)
Requirement already satisfied: packaging in c:\users\Admin\appdata\roaming\pytho
n\python310-32\site-packages (from sip) (21.3)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in c:\users\Admin\appdat
a\roaming\python\python310-32\site-packages (from packaging->sip) (3.0.6)
Building wheels for collected packages: sip

运行 非常完美。但是;

  Building wheel for sip (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Program Files\Python310-32\python.exe' 'C:\Users\Admin\AppData\R
oaming\Python\Python310-32\site-packages\pip\_vendor\pep517\in_process\_in_proce
ss.py' build_wheel 'C:\Users\Admin\AppData\Local\Temp\tmpbp29upup'
       cwd: C:\Users\Admin\AppData\Local\Temp\pip-install-z5zff4sm\sip_b8fe66d11
90b4a5bb4ab29314f68ed38
  Complete output (147 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-3.10
  creating build\lib.win32-3.10\sipbuild
  copying sipbuild\abstract_builder.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\abstract_project.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\api.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\argument_parser.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\bindings.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\buildable.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\builder.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\configurable.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\distutils_builder.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\exceptions.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\helpers.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\installable.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\project.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\pyproject.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\py_versions.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\setuptools_builder.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\version.py -> build\lib.win32-3.10\sipbuild
  copying sipbuild\__init__.py -> build\lib.win32-3.10\sipbuild
  creating build\lib.win32-3.10\sipbuild\distinfo
  copying sipbuild\distinfo\distinfo.py -> build\lib.win32-3.10\sipbuild\distinf
o
  copying sipbuild\distinfo\main.py -> build\lib.win32-3.10\sipbuild\distinfo
  copying sipbuild\distinfo\__init__.py -> build\lib.win32-3.10\sipbuild\distinf
o
  creating build\lib.win32-3.10\sipbuild\module
  copying sipbuild\module\abi_version.py -> build\lib.win32-3.10\sipbuild\module

  copying sipbuild\module\main.py -> build\lib.win32-3.10\sipbuild\module
  copying sipbuild\module\module.py -> build\lib.win32-3.10\sipbuild\module
  copying sipbuild\module\__init__.py -> build\lib.win32-3.10\sipbuild\module
  creating build\lib.win32-3.10\sipbuild\tools
  copying sipbuild\tools\build.py -> build\lib.win32-3.10\sipbuild\tools
  copying sipbuild\tools\install.py -> build\lib.win32-3.10\sipbuild\tools
  copying sipbuild\tools\sdist.py -> build\lib.win32-3.10\sipbuild\tools
  copying sipbuild\tools\wheel.py -> build\lib.win32-3.10\sipbuild\tools
  copying sipbuild\tools\__init__.py -> build\lib.win32-3.10\sipbuild\tools
  creating build\lib.win32-3.10\sipbuild\module\source
  creating build\lib.win32-3.10\sipbuild\module\source
  copying sipbuild\module\source\apiversions.c -> build\lib.win32-3.10\sipbui
ld\module\source
  copying sipbuild\module\source\array.c -> build\lib.win32-3.10\sipbuild\mod
ule\source
  copying sipbuild\module\source\array.h -> build\lib.win32-3.10\sipbuild\mod
ule\source
  copying sipbuild\module\source\bool.cpp -> build\lib.win32-3.10\sipbuild\mo
dule\source
  copying sipbuild\module\source\descriptors.c -> build\lib.win32-3.10\sipbui
ld\module\source
  copying sipbuild\module\source\int_convertors.c -> build\lib.win32-3.10\sip
build\module\source
  copying sipbuild\module\source\LICENSE -> build\lib.win32-3.10\sipbuild\mod
ule\source
  copying sipbuild\module\source\LICENSE-GPL2 -> build\lib.win32-3.10\sipbuil
d\module\source
  copying sipbuild\module\source\LICENSE-GPL3 -> build\lib.win32-3.10\sipbuil
d\module\source
  copying sipbuild\module\source\MANIFEST.in -> build\lib.win32-3.10\sipbuild
\module\source
  copying sipbuild\module\source\objmap.c -> build\lib.win32-3.10\sipbuild\mo
dule\source
  copying sipbuild\module\source\pyproject.toml -> build\lib.win32-3.10\sipbu
ild\module\source
  copying sipbuild\module\source\qtlib.c -> build\lib.win32-3.10\sipbuild\mod
ule\source
  copying sipbuild\module\source\README.in -> build\lib.win32-3.10\sipbuild\m
odule\source
  copying sipbuild\module\source\setup.cfg.in -> build\lib.win32-3.10\sipbuil
d\module\source
  copying sipbuild\module\source\setup.py.in -> build\lib.win32-3.10\sipbuild
\module\source
  copying sipbuild\module\source\sip.h.in -> build\lib.win32-3.10\sipbuild\mo
dule\source
  copying sipbuild\module\source\sip.pyi -> build\lib.win32-3.10\sipbuild\mod
ule\source
  copying sipbuild\module\source\sip.rst.in -> build\lib.win32-3.10\sipbuild\
module\source
  copying sipbuild\module\source\sipint.h -> build\lib.win32-3.10\sipbuild\mo
dule\source
  copying sipbuild\module\source\siplib.c -> build\lib.win32-3.10\sipbuild\mo
dule\source
  copying sipbuild\module\source\threads.c -> build\lib.win32-3.10\sipbuild\m
odule\source
  copying sipbuild\module\source\voidptr.c -> build\lib.win32-3.10\sipbuild\m
odule\source
  creating build\lib.win32-3.10\sipbuild\module\source
  copying sipbuild\module\source\array.c -> build\lib.win32-3.10\sipbuild\mod
ule\source
  copying sipbuild\module\source\array.h -> build\lib.win32-3.10\sipbuild\mod
ule\source
  copying sipbuild\module\source\bool.cpp -> build\lib.win32-3.10\sipbuild\mo
dule\source
  copying sipbuild\module\source\descriptors.c -> build\lib.win32-3.10\sipbui
ld\module\source
  copying sipbuild\module\source\int_convertors.c -> build\lib.win32-3.10\sip
build\module\source
  copying sipbuild\module\source\LICENSE -> build\lib.win32-3.10\sipbuild\mod
ule\source
  copying sipbuild\module\source\LICENSE-GPL2 -> build\lib.win32-3.10\sipbuil
d\module\source
  copying sipbuild\module\source\LICENSE-GPL3 -> build\lib.win32-3.10\sipbuil
d\module\source
  copying sipbuild\module\source\MANIFEST.in -> build\lib.win32-3.10\sipbuild
\module\source
  copying sipbuild\module\source\objmap.c -> build\lib.win32-3.10\sipbuild\mo
dule\source
  copying sipbuild\module\source\pyproject.toml -> build\lib.win32-3.10\sipbu
ild\module\source
  copying sipbuild\module\source\README.in -> build\lib.win32-3.10\sipbuild\m
odule\source
  copying sipbuild\module\source\setup.cfg.in -> build\lib.win32-3.10\sipbuil
d\module\source
  copying sipbuild\module\source\setup.py.in -> build\lib.win32-3.10\sipbuild
\module\source
  copying sipbuild\module\source\sip.h.in -> build\lib.win32-3.10\sipbuild\mo
dule\source
  copying sipbuild\module\source\sip.pyi -> build\lib.win32-3.10\sipbuild\mod
ule\source
  copying sipbuild\module\source\sip.rst.in -> build\lib.win32-3.10\sipbuild\
module\source
  copying sipbuild\module\source\sipint.h -> build\lib.win32-3.10\sipbuild\mo
dule\source
  copying sipbuild\module\source\siplib.c -> build\lib.win32-3.10\sipbuild\mo
dule\source
  copying sipbuild\module\source\threads.c -> build\lib.win32-3.10\sipbuild\m
odule\source
  copying sipbuild\module\source\voidptr.c -> build\lib.win32-3.10\sipbuild\m
odule\source
  running build_ext
  Traceback (most recent call last):
    File "C:\Users\Admin\AppData\Roaming\Python\Python310-32\site-packages\pip\_
vendor\pep517\in_process\_in_process.py", line 363, in <module>
      main()
    File "C:\Users\Admin\AppData\Roaming\Python\Python310-32\site-packages\pip\_
vendor\pep517\in_process\_in_process.py", line 345, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "C:\Users\Admin\AppData\Roaming\Python\Python310-32\site-packages\pip\_
vendor\pep517\in_process\_in_process.py", line 261, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\build_meta.py", line 230, in build_wheel
      return self._build_with_temp_dir(['bdist_wheel'], '.whl',
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\build_meta.py", line 215, in _build_with_temp_dir
      self.run_setup()
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\build_meta.py", line 267, in run_setup
      super(_BuildMetaLegacyBackend,
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\build_meta.py", line 158, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 49, in <module>
      setup(
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\__init__.py", line 155, in setup
      return distutils.core.setup(**attrs)
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\core.py", line 148, in setup
      return run_commands(dist)
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\core.py", line 163, in run_commands
      dist.run_commands()
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\dist.py", line 967, in run_commands
      self.run_command(cmd)
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\dist.py", line 986, in run_command
      cmd_obj.run()
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\wheel\bdist_wheel.py", line 299, in run
      self.run_command('build')
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\dist.py", line 986, in run_command
      cmd_obj.run()
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\dist.py", line 986, in run_command
      cmd_obj.run()
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\command\build_ext.py", line 79, in run
      _build_ext.run(self)
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\command\build_ext.py", line 339, in run
      self.build_extensions()
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\command\build_ext.py", line 448, in build_ext
ensions
      self._build_extensions_serial()
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\command\build_ext.py", line 473, in _build_ex
tensions_serial
      self.build_extension(ext)
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\command\build_ext.py", line 202, in build_extension
      _build_ext.build_extension(self, ext)
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\command\build_ext.py", line 528, in build_ext
ension
      objects = self.compiler.compile(sources,
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\_msvccompiler.py", line 327, in compile
      self.initialize()
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\_distutils\_msvccompiler.py", line 224, in initialize
      vc_env = _get_vc_env(plat_spec)
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\msvc.py", line 316, in msvc14_get_vc_env
      return _msvc14_get_vc_env(plat_spec)
    File "C:\Users\Admin\AppData\Local\Temp\pip-build-env-py_mvk7m\overlay\Lib\s
ite-packages\setuptools\msvc.py", line 270, in _msvc14_get_vc_env
      raise distutils.errors.DistutilsPlatformError(
  setuptools._distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0
 or greater is required. Get it with "Microsoft C++ Build Tools": https://visual
studio.microsoft.com/visual-cpp-build-tools/
  ----------------------------------------
  ERROR: Failed building wheel for sip
Failed to build sip
ERROR: Could not build wheels for sip, which is required to install pyproject.toml-based projects

你能帮我找出问题所在吗? 我写了这个(从 https://pypi.org/project/sip/ 复制的行):

pip install sip

OS:Microsoft Windows 8.1 Pro [版本 6.3.9600]

Python版本:3.10.0

画中画版本:21.3.1

刚试了一下在venv中安装sip,很顺利。我猜你需要升级 pip:

pip install --upgrade pip

然后运行再次安装脚本:

pip install sip