Installing wxPython: DistutilsPlatformError: Microsoft Visual C++ 14.2 or greater is required

Erik 1 Reputation point
2021-12-13T23:30:13.627+00:00

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)

As an image for those who prefer seeing it that way:

157331-cinstalled.png

When trying to install wxPython in my project's virtualenv, I run into this stacktrace:

Command '"***\venv\Scripts\python.exe" -c "import setuptools, distutils.msvc9compiler as msvc; mc = msvc.MSVCCompiler(); mc.initialize(); print(mc.cc)"' failed with exit code 1.  
Traceback (most recent call last):  
  
  File "<string>", line 1, in <module>  
  
  File "***\AppData\Local\Programs\Python\Python310\lib\distutils\msvc9compiler.py", line 371, in initialize  
  
    vc_env = query_vcvarsall(VERSION, plat_spec)  
  
  File "***\Documents\PycharmProjects\Trakkit\venv\lib\site-packages\setuptools\msvc.py", line 140, in msvc9_query_vcvarsall  
  
    return EnvironmentInfo(arch, ver).return_env()  
  
  File "***\Documents\PycharmProjects\Trakkit\venv\lib\site-packages\setuptools\msvc.py", line 1740, in return_env  
  
    [self.VCIncludes,  
  
  File "***\Documents\PycharmProjects\Trakkit\venv\lib\site-packages\setuptools\msvc.py", line 1282, in VCIncludes  
  
    return [join(self.si.VCInstallDir, 'Include'),  
  
  File "***\Documents\PycharmProjects\Trakkit\venv\lib\site-packages\setuptools\msvc.py", line 840, in VCInstallDir  
  
    raise distutils.errors.DistutilsPlatformError(msg)  
  
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), as well as venv/Scripts/pip install --upgrade setuptools.

Am I missing something? Perhaps some sort of path to tell pip / python where to find these build tools?

Developer technologies Visual Studio Setup
{count} votes

3 answers

Sort by: Most helpful
  1. Anna Xiu-MSFT 31,056 Reputation points Microsoft External Staff
    2021-12-14T07:43:39.59+00:00

    Hi @Erik ,

    Currently, Microsoft Q&A supports the products listed over here: supported topics (more to be added later on).
    Your question about wxPython is not supported currently.
    You can ask in the dedicated wxPython forum over here: https://stackoverflow.com/questions/tagged/wxpython.

    Thank you for your understanding!

    Sincerely,
    Anna
    *
    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Erik 1 Reputation point
    2021-12-14T08:16:12.787+00:00

    Hi @Anna Xiu-MSFT ,

    It's not a wxPython specific question - the question, put very simply, is: "what do I need to configure to ensure that I can install ANY package which needs to be compiled - how do I tell my system where to find the compiler?"

    0 comments No comments

  3. Oleksis Fraga 1 Reputation point
    2021-12-22T06:18:34.923+00:00

    Hi @Erik

    I think the issue is setuptools.msvc and how manage the redist_path and prefixes with Microsoft C++ Build Tools in Visual Studio 2019

    You can check more in the gist: Compile wxPython 4.1.2a1 using Microsoft C++ Build Tools 2019

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.