错误:无法构建PyGObject的轮子,这是安装基于pyproject.toml的项目所需的。

3

我一直在尝试安装PyGObject库,但在构建轮时它一直给我这个错误:

    gi\gimodule.c: fatal error C1083: Cannot open include file: 'msvc_recommended_pragmas.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for PyGObject
Failed to build PyGObject
ERROR: Could not build wheels for PyGObject, which is required to install pyproject.toml-based projects

我已经安装了 gtk3 和 gtk4,并在实际目录中进行了检查, 'msvc_recommended_pragmas.h' 文件也存在,我甚至将包含该文件的目录添加到系统变量路径中并使用管理员权限运行命令行,以防权限问题,但没有任何作用。

以下是更多错误信息:

 building 'gi._gi' extension
      creating build\temp.win-amd64-cpython-310
      creating build\temp.win-amd64-cpython-310\Release
      creating build\temp.win-amd64-cpython-310\Release\gi
      "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DPY_SSIZE_T_CLEAN -IC:\Users\vibha\AppData\Local\Temp\pip-install-yehnxbt1\pygobject_f040809a65874c25ad61265906443b90 -IC:\Users\vibha\AppData\Local\Temp\pip-install-yehnxbt1\pygobject_f040809a65874c25ad61265906443b90\gi -IC:\Users\vibha\AppData\Local\Programs\Python\Python310\include -IC:\Users\vibha\AppData\Local\Programs\Python\Python310\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" -Imsvc_recommended_pragmas.h /Tcgi\gimodule.c /Fobuild\temp.win-amd64-cpython-310\Release\gi\gimodule.obj -FImsvc_recommended_pragmas.h
      gimodule.c
      gi\gimodule.c: fatal error C1083: Cannot open include file: 'msvc_recommended_pragmas.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for PyGObject
Failed to build PyGObject
ERROR: Could not build wheels for PyGObject, which is required to install pyproject.toml-based projects
2个回答

2

唯一被接受的答案:

如果你只是凡人,实际上在Windows上使用PyGObject是不可能的。

最好的方法是:通过WSL使用Python,一切都会神奇地正常工作。遇到的其他错误可以通过sudo apt install something解决。


-2
我之前遇到过类似的问题。
  1. 安装PyGObject的二进制发行版

    pip install pygobject-binary
    
  2. 检查你的PATH:确保包含cl.exe的目录已添加到你的PATH中。使用以下命令添加:

    set PATH=%PATH%;"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\bin\HostX86\x64"
    

    将路径设置为cl.exe在你的计算机上的位置。

现在再试着安装PyGObject

pygobject-binary不存在 错误:找不到满足要求的版本 pygobject-binary(来自版本:none) - Konrad

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接