Installing wxPython on Windows: DistutilsPlatformError: Microsoft Visual C++ 14.2 or greater is required
Installing wxPython on Windows: DistutilsPlatformError: Microsoft Visual C++ 14.2 or greater is required
我已经安装了:
- Python 3.10.1
- PyCharm 社区 2021.3
- Visual Studio 构建工具 2022,包括:
- C++ 构建工具核心功能
- C++ 2022 可再发行更新
- C++ 核心桌面功能
- MSVC v143 - VS 2022 C++ x64/x86 构建工具(最新)
- Windows 10 个 SDK (10.0.19041.0)
- 用于 Windows
的 C++ CMake 工具
- 测试工具核心功能——构建工具
- C++ AddressSanitizer
- v143 构建工具的 C++/CLI 支持(最新)
- v143 构建工具的 C++ 模块(x64/x86 - 实验)
当尝试在我的项目的 virtualenv 中安装 wxPython 时,我得到这个错误:
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.2 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
错误和我在互联网上(包括此处)可以找到的任何内容都告诉我下载 C++ 构建工具并安装 C++ 14.2 或更高版本/最新版本。我有:
- 做到了(见上面的列表),
- 重新启动
venv/Scripts/pip install --upgrade setuptools
venv/Scripts/pip install --upgrade wheel
venv/Scripts/pip install --upgrade pip
我在这里错过了什么?我是否需要在某处配置某种路径变量,以便 pip/wheel/setuptools 知道在哪里可以找到编译器?
我也遇到了同样的问题。解决了我使用 Python 3.9.9 的问题。
它可能与 Python 3.10.1 中的 distutils 问题有关,并带有来自 msvc9compiler.py:
的警告
DeprecationWarning: The distutils package is deprecated and slated for
removal in Python 3.12
这导致:
raise DistutilsPlatformError("Unable to find vcvarsall.bat")
当前的 wxPython 4.1.1 与 windows 上的 python 3.10 不兼容(它适用于 Linux)。您可以下载旧版本的 Visual Studio Build Tools 来解决 DistutilsPlatformError 的问题,但是您将无法在 windows 上的 python 3.10 上成功安装。我找到了问题的解决方案,link 是 Compile_wxPython_4.1.2a1_Python3.10_Windows。我无法编译它,但是使用该过程生成的 whl 文件有一个 link。我使用命令 pip install wxPython-4.1.2a1-cp310-cp310-win_amd64.whl
下载并安装了它
我相信在不久的将来 4.1.2 将发布到 PyPy,您将能够使用 pip 安装它。
目前正在修复此问题。或者更确切地说,它是固定的,并且很快就会通过修复进行 PR。我编写了一个正确的 MSVC 构建环境脚本,而不是 distutils 或 setuptool 附带的脚本,在设置 MSVC 构建环境时,它们都不能正常工作。
这是我编写的脚本的 link,用于正确设置构建环境
https://github.com/kdschlosser/python_msvc
这是一个 link 到 wxPython
的工作分支
https://github.com/oleksis/Phoenix/tree/try-pyMSVC
wxPython 无法正确编译的问题是因为 setuptools 或 distutils 都没有正确检测 Visual Studio 2022 的能力。我的脚本使用 COM 接口来收集设置构建环境所需的信息。没有使用 vcvar*.bat 文件设置环境。
我已经安装了:
- Python 3.10.1
- PyCharm 社区 2021.3
- Visual Studio 构建工具 2022,包括:
- C++ 构建工具核心功能
- C++ 2022 可再发行更新
- C++ 核心桌面功能
- MSVC v143 - VS 2022 C++ x64/x86 构建工具(最新)
- Windows 10 个 SDK (10.0.19041.0)
- 用于 Windows 的 C++ CMake 工具
- 测试工具核心功能——构建工具
- C++ AddressSanitizer
- v143 构建工具的 C++/CLI 支持(最新)
- v143 构建工具的 C++ 模块(x64/x86 - 实验)
当尝试在我的项目的 virtualenv 中安装 wxPython 时,我得到这个错误:
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.2 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
错误和我在互联网上(包括此处)可以找到的任何内容都告诉我下载 C++ 构建工具并安装 C++ 14.2 或更高版本/最新版本。我有:
- 做到了(见上面的列表),
- 重新启动
venv/Scripts/pip install --upgrade setuptools
venv/Scripts/pip install --upgrade wheel
venv/Scripts/pip install --upgrade pip
我在这里错过了什么?我是否需要在某处配置某种路径变量,以便 pip/wheel/setuptools 知道在哪里可以找到编译器?
我也遇到了同样的问题。解决了我使用 Python 3.9.9 的问题。 它可能与 Python 3.10.1 中的 distutils 问题有关,并带有来自 msvc9compiler.py:
的警告DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12
这导致:
raise DistutilsPlatformError("Unable to find vcvarsall.bat")
当前的 wxPython 4.1.1 与 windows 上的 python 3.10 不兼容(它适用于 Linux)。您可以下载旧版本的 Visual Studio Build Tools 来解决 DistutilsPlatformError 的问题,但是您将无法在 windows 上的 python 3.10 上成功安装。我找到了问题的解决方案,link 是 Compile_wxPython_4.1.2a1_Python3.10_Windows。我无法编译它,但是使用该过程生成的 whl 文件有一个 link。我使用命令 pip install wxPython-4.1.2a1-cp310-cp310-win_amd64.whl
下载并安装了它
我相信在不久的将来 4.1.2 将发布到 PyPy,您将能够使用 pip 安装它。
目前正在修复此问题。或者更确切地说,它是固定的,并且很快就会通过修复进行 PR。我编写了一个正确的 MSVC 构建环境脚本,而不是 distutils 或 setuptool 附带的脚本,在设置 MSVC 构建环境时,它们都不能正常工作。
这是我编写的脚本的 link,用于正确设置构建环境
https://github.com/kdschlosser/python_msvc
这是一个 link 到 wxPython
的工作分支https://github.com/oleksis/Phoenix/tree/try-pyMSVC
wxPython 无法正确编译的问题是因为 setuptools 或 distutils 都没有正确检测 Visual Studio 2022 的能力。我的脚本使用 COM 接口来收集设置构建环境所需的信息。没有使用 vcvar*.bat 文件设置环境。