即使从 Microsoft Visual Studio 安装了运行时库,我在安装 webview 库时也遇到问题。我也有最新的 python 版本。
======== 命令错误========
C:\Users\rouna>pip install webview
Collecting webview
Using cached webview-0.1.5.tar.gz (18 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: webview
Building wheel for webview (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [19 lines of output]
running bdist_wheel
running build
running build_ext
building 'webview' extension
creating build
creating build\temp.win-amd64-3.10
creating build\temp.win-amd64-3.10\Release
creating build\temp.win-amd64-3.10\Release\webview
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DWEBVIEW_WINAPI=1 -IC:\Users\rouna\AppData\Local\Programs\Python\Python310\include -IC:\Users\rouna\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 -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um /Tcwebview/webview.c /Fobuild\temp.win-amd64-3.10\Release\webview/webview.obj
webview.c
C:\Users\rouna\AppData\Local\Temp\pip-install-67e1r8x0\webview_0f6456dc97e347ebac52664734281c5e\webview\webview.h(1085): warning C4477: 'sscanf' : format string '%02x' requires an argument of type 'unsigned int *', but variadic argument 1 has type 'char *'
C:\Users\rouna\AppData\Local\Temp\pip-install-67e1r8x0\webview_0f6456dc97e347ebac52664734281c5e\webview\webview.h(1085): note: consider using '%hhx' in the format string
C:\Users\rouna\AppData\Local\Temp\pip-install-67e1r8x0\webview_0f6456dc97e347ebac52664734281c5e\webview\webview.h(1338): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
webview/webview.c(117): error C2065: 'PATH_MAX': undeclared identifier
webview/webview.c(117): error C2057: expected constant expression
webview/webview.c(117): error C2466: cannot allocate an array of constant size 0
webview/webview.c(117): error C2133: 'result': unknown size
webview/webview.c(123): warning C4034: sizeof returns 0
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 webview
Running setup.py clean for webview
Failed to build webview
ERROR: Could not build wheels for webview, which is required to install pyproject.toml-based projects
我尝试安装 Microsoft Visual C ++ 2015-2022 Redistributable (x86) - 14.32.31326
请使用以下命令。
pip install pywebview