4

I have installed:

  • Python 3.10.1
  • PyCharm Community 2021.3
  • Visual Studio Build Tools 2022, including:
    • C++ Build Tools Core Features
    • C++ 2022 Redistributable Update
    • C++ core desktop features
    • MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
    • Windows 10 SDK (10.0.19041.0)
    • C++ CMake tools for Windows
    • Testing tools core features - Build Tools
    • C++ AddressSanitizer
    • C++/CLI support for v143 build tools (Latest)
    • C++ Modules for v143 build tools (x64/x86 - experimental)

When trying to install wxPython in my project's virtualenv, I get this error:

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/

Both the error and anything I can find on the internet (including here) tells me to download C++ build tools and install C++ 14.2 or greater / the latest version. I have:

  • done that (see the list above),
  • rebooted
  • venv/Scripts/pip install --upgrade setuptools
  • venv/Scripts/pip install --upgrade wheel
  • venv/Scripts/pip install --upgrade pip

What am I missing here? Is there some sort of path variable that I need to configure somewhere so pip/wheel/setuptools knows where to find the compiler?

2
  • I'd guess distutils just hasn't been updated yet to support vs 2022, you might have more success with vs 2019 Commented Dec 14, 2021 at 8:40
  • Alas, no luck. Uninstalled the 2022 build tools and installed the 2019 ones, including MSVC v142, Windows 10 SDK, C++ CMake tols for Windows, Testing tools core features - Build Tools, C++ AddressSanitizer and C++/CLI support for v142 build tools. Commented Dec 14, 2021 at 10:46

4 Answers 4

3

I have the same problem. Solved for me to use Python 3.9.9. Its maybe about a distutils problem in Python 3.10.1 with this warning from msvc9compiler.py:

DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12

This leads to:

raise DistutilsPlatformError("Unable to find vcvarsall.bat")

Sign up to request clarification or add additional context in comments.

1 Comment

This is not very useful if the purpose is to upgrade to Python 3.10
2

The current wxPython 4.1.1 is not compatible with python 3.10 on windows (it works on Linux). You can download an older version of Visual Studio Build Tools to get around the issue with the DistutilsPlatformError, however you will not be able to successfully install on python 3.10 on windows. I found a solution for the problem, the link is Compile_wxPython_4.1.2a1_Python3.10_Windows. I was not able to compile it but there is a link to the whl file that was bult using the procedure. I downloaded and installed it using the command pip install wxPython-4.1.2a1-cp310-cp310-win_amd64.whl I am confident in the near future 4.1.2 will be released to PyPy and you will be able to install it using pip.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
2

The answers here have already provided the right pointers, but in this anser I would like to list all the necessary steps directly so you don't have to visit other resources, and it also provides the solution for both 64-bit and 32-bit versions of Python 3.10.x.

Solution for 64-bit version of Python 3.10.x

  1. Download the wxPython wheel file directly here: wxPython-4.1.2a1-cp310-cp310-win_amd64.whl.
  2. Using the Windows command line, move to the folder where you downloaded the wheel file.
  3. Run: pip install wxPython-4.1.2a1-cp310-cp310-win_amd64.whl

Solution for 32-bit version of Python 3.10.x

Prerequisites

Build wxPython

In the Windows command line ran as Administrator, execute the following commands:

gh repo clone wxWidgets/Phoenix
cd .\Phoenix\
git submodule update --init --recursive
python -m venv venv
.\venv\Scripts\activate
pip install -r .\requirements.txt
python build.py dox etg --nodoc sip build

Create wheel

Still in the command line, execute the following:

python setup.py bdist_wheel

Install wheel

Still in the command line, execute the following:

cd dist
pip install <created-wheel-filename>

The <created-wheel-filename> should be the wheel you just created, so something like: wxPython-4.2.0a1-cp310-cp310-win32.whl

Source

1 Comment

works for me: pip install https://github.com/oleksis/youtube-dl-gui/releases/download/v1.8.2/wxPython-4.1.2a1-cp310-cp310-win_amd64.whl
0

This problem is currently being fixed. Or rather it is fixed and a PR will be made with the fix pretty soon. I wrote a proper MSVC build environment script instead of the one that comes with either distutils or setuptool neither of which really work correctly when setting up an MSVC build environment.

Here is a link to the script I wrote that handles setting up the build environment properly

https://github.com/kdschlosser/python_msvc

and here is a link to a working fork of wxPython

https://github.com/oleksis/Phoenix/tree/try-pyMSVC

The problem with wxPython compiling properly is because neither setuptools or distutils has the capability of detecting Visual Studio 2022 properly. My script uses COM interfaces to collect the information needed to set up the build environment. The environment is set up without using the vcvar*.bat files.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.