Failed building wheel for wxPython (MacOS 12.0.1)

Attempts to install wxPython 4.1.1 inside a active Python 3.9.9 virtual environment on MacOS 12.0.1 Monterey is failing with the error:

ERROR: Failed building wheel for wxPython

The following pip modules are installed:

  • pip 21.3.1
  • setuptools 59.0.1
  • wheel 0.37.0

Are there any minimal compiler requirements needed for MacOS when installing wxPython?

The full error trace is here:

(.venv) system@local MyProjectName % pip3 install -U wxPython
Collecting wxPython
  Using cached wxPython-4.1.1.tar.gz (66.0 MB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pillow in ./.venv/lib/python3.9/site-packages (from wxPython) (8.4.0)
Requirement already satisfied: six in ./.venv/lib/python3.9/site-packages (from wxPython) (1.16.0)
Requirement already satisfied: numpy in ./.venv/lib/python3.9/site-packages (from wxPython) (1.21.4)
Building wheels for collected packages: wxPython
  Building wheel for wxPython (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: '/Users/Dev/Projects/MyProjectName/.venv/bin/python3.9' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/setup.py'"'"'; __file__='"'"'/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-wheel-dffxjqym
       cwd: /private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/
  Complete output (261 lines):
  /Users/Dev/Projects/MyProjectName/.venv/lib/python3.9/site-packages/setuptools/dist.py:717: UserWarning: Usage of dash-separated 'license-file' will not be supported in future versions. Please use the underscore name 'license_file' instead
    warnings.warn(
  /Users/Dev/Projects/MyProjectName/.venv/lib/python3.9/site-packages/setuptools/dist.py:294: DistDeprecationWarning: use_2to3 is ignored.
    warnings.warn(f"{attr} is ignored.", DistDeprecationWarning)
  running bdist_wheel
  running build
  WARNING: Building this way assumes that all generated files have been
  generated already.  If that is not the case then use build.py directly
  to generate the source and perform the build stage.  You can use
  --skip-build with the bdist_* or install commands to avoid this
  message and the wxWidgets and Phoenix build steps in the future.
  
  "/Users/Dev/Projects/MyProjectName/.venv/bin/python3.9" -u build.py build
  Will build using: "/Users/Dev/Projects/MyProjectName/.venv/bin/python3.9"
  3.9.9 (main, Nov 21 2021, 03:16:13)
  [Clang 13.0.0 (clang-1300.0.29.3)]
  Python's architecture is 64bit
  cfg.VERSION: 4.1.1
  
  Running command: build
  Running command: build_wx
  wxWidgets build options: ['--wxpython', '--unicode', '--osx_cocoa']
  Configure options: ['--enable-unicode', '--with-osx_cocoa', '--enable-sound', '--enable-graphics_ctx', '--enable-display', '--enable-geometry', '--enable-debug_flag', '--enable-optimise', '--disable-debugreport', '--enable-uiactionsim', '--enable-autoidman', '--with-macosx-version-min=10.10']
  /private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/ext/wxWidgets/configure --enable-unicode --with-osx_cocoa --enable-sound --enable-graphics_ctx --enable-display --enable-geometry --enable-debug_flag --enable-optimise --disable-debugreport --enable-uiactionsim --enable-autoidman --with-macosx-version-min=10.10
  checking build system type... arm-apple-darwin21.1.0
  checking host system type... arm-apple-darwin21.1.0
  checking for toolkit... osx_cocoa
  checking for gcc... gcc
  checking whether the C compiler works... yes
  checking for C compiler default output file name... a.out
  checking for suffix of executables...
  checking whether we are cross compiling... no
  checking for suffix of object files... o
  checking whether we are using the GNU C compiler... yes
  checking whether gcc accepts -g... yes
  checking for gcc option to accept ISO C89... none needed
  checking whether we are using the Intel C compiler... no
  checking how to run the C preprocessor... gcc -E
  checking for grep that handles long lines and -e... /usr/bin/grep
  checking for egrep... /usr/bin/grep -E
  checking whether gcc needs -traditional... no
  checking for g++... g++
  checking whether we are using the GNU C++ compiler... yes
  checking whether g++ accepts -g... yes
  checking whether we are using the Intel C++ compiler... no
  checking whether we are using the IBM xlC C++ compiler... no
  checking whether g++ supports C++11 features with -std=gnu++11... yes
  checking for ar... ar
  checking if C compiler (gcc -mmacosx-version-min=10.10) works with SDK/version options... yes
  checking if C++ compiler (g++ -std=gnu++11 -mmacosx-version-min=10.10) works with SDK/version options... yes
  checking if CoreFoundation/CFBase.h is usable... yes
  checking for ANSI C header files... yes
  checking for sys/types.h... yes
  checking for sys/stat.h... yes
  checking for stdlib.h... yes
  checking for string.h... yes
  checking for memory.h... yes
  checking for strings.h... yes
  checking for inttypes.h... yes
  checking for stdint.h... yes
  checking for unistd.h... yes
  checking for langinfo.h... yes
  checking for wchar.h... yes
  checking for sys/select.h... yes
  checking for cxxabi.h... yes
  checking for an ANSI C-conforming const... yes
  checking for inline... inline
  checking size of short... 2
  checking size of void *... 8
  checking size of int... 4
  checking size of long... 8
  checking size of size_t... 8
  checking size of long long... 8
  checking size of wchar_t... 4
  checking for va_copy... yes
  checking for _FILE_OFFSET_BITS value needed for large files... 64
  checking if large file support is available... yes
  checking for _LARGEFILE_SOURCE value needed for large files... no
  checking whether byte ordering is bigendian... no
  checking for __sync_fetch_and_add and __sync_sub_and_fetch builtins... yes
  checking for libraries directories... /usr/lib
  checking for cos... yes
  checking for floor... yes
  checking if floating point functions link without -lm... yes
  checking for pkg-config... /opt/homebrew/bin/pkg-config
  checking pkg-config is at least version 0.9.0... yes
  configure: WARNING: Defaulting to the builtin regex library for Unicode build.
  checking for zlib.h >= 1.1.4... no
  checking for zlib.h... (cached) no
  configure: WARNING: zlib library not found or too old, will use built-in instead
  checking whether zlib.h file exists... yes
  checking for png.h > 0.90... no
  checking for png.h... (cached) no
  configure: WARNING: system png library not found or too old, will use built-in instead
  checking whether png.c file exists... yes
  checking for jpeglib.h... no
  configure: WARNING: system jpeg library not found, will use built-in instead
  checking whether jpeglib.h file exists... yes
  checking lzma.h usability... no
  checking lzma.h presence... no
  checking for lzma.h... no
  checking for jbg_dec_init in -ljbig... no
  checking for LIBTIFF... not found via pkg-config
  checking for tiffio.h... no
  configure: WARNING: system tiff library not found, will use built-in instead
  checking whether tiff.h file exists... yes
  checking for expat.h... yes
  checking if expat.h is valid C++ header... yes
  checking for XML_ParserCreate in -lexpat... yes
  checking for X11/Xlib.h... no
  checking for X11/XKBlib.h... no
  checking if the linker accepts --version-script... no
  checking for symbols visibility support... yes
  checking for broken libstdc++ visibility... no
  checking for mode_t... yes
  checking for off_t... yes
  checking for pid_t... yes
  checking for size_t... yes
  checking for ssize_t... yes
  checking if size_t is unsigned int... no
  checking if size_t is unsigned long... yes
  checking if wchar_t is separate type... yes
  checking for pw_gecos in struct passwd... yes
  checking for wcslen... yes
  checking for wcsftime... yes
  checking for mbstate_t... yes
  checking for wcsrtombs... yes
  checking for snprintf... yes
  checking for vsnprintf... yes
  checking for vsscanf... yes
  checking for vsnprintf declaration... yes
  checking if vsnprintf declaration is broken... no
  checking for snprintf declaration... yes
  checking if snprintf supports positional arguments... yes
  checking for vsscanf declaration... yes
  checking if vsscanf() declaration is broken... no
  checking for putws... no
  checking for fputws... yes
  checking for wprintf... yes
  checking for vswprintf... yes
  checking for vswscanf... yes
  checking for _vsnwprintf... no
  checking for fsync... yes
  checking for round... yes
  checking for iconv... yes
  checking if iconv needs const... no
  checking for sigaction... yes
  checking for sa_handler type... int
  checking for backtrace()... yes
  checking for library containing backtrace... none required
  checking for __cxa_demangle() in <cxxabi.h>... yes
  checking for mkstemp... yes
  checking for statfs... yes
  checking for statfs declaration... yes
  checking for fcntl... yes
  checking for setenv... yes
  checking for unsetenv... yes
  checking for uname... yes
  checking for strtok_r... yes
  checking for inet_addr... yes
  checking for inet_aton... yes
  checking for fdopen... yes
  checking for sysconf... yes
  checking for getpwuid_r... yes
  checking for getgrgid_r... yes
  checking for the pthreads library -lpthread... yes
  checking if more special flags are required for pthreads... no
  checking for pthread_setconcurrency... yes
  checking for pthread_cleanup_push/pop... yes
  checking for sched.h... yes
  checking for sched_yield... yes
  checking for pthread_attr_getschedpolicy... yes
  checking for pthread_attr_setschedparam... yes
  checking for sched_get_priority_max... yes
  checking for pthread_cancel... yes
  checking for pthread_mutex_timedlock... no
  configure: WARNING: wxMutex::LockTimeout() will not work
  checking for pthread_attr_setstacksize... yes
  checking for pthread_mutexattr_t... yes
  checking for pthread_mutexattr_settype declaration... yes
  checking for abi::__forced_unwind() in <cxxabi.h>... no
  checking for localtime_r... yes
  checking for gmtime_r... yes
  checking how many arguments gethostbyname_r() takes... can't tell
  checking for gethostbyname... yes
  checking how many arguments getservbyname_r() takes... no
  checking for getservbyname... yes
  checking for dlopen... yes
  checking for dladdr... yes
  checking whether inotify is usable... no
  checking for sys/event.h... yes
  checking for SNDCTL_DSP_SPEED in sys/soundcard.h... no
  checking xlocale.h usability... yes
  checking xlocale.h presence... yes
  checking for xlocale.h... yes
  checking for locale_t... yes
  checking for sys/epoll.h... no
  configure: WARNING: sys/epoll.h not available, wxEpollDispatcher disabled
  checking for gettimeofday... yes
  checking whether gettimeofday takes two arguments... yes
  checking for timezone variable in <time.h>... timezone
  checking for localtime... yes
  checking for tm_gmtoff in struct tm... yes
  checking for _NL_TIME_FIRST_WEEKDAY in langinfo.h... no
  checking for setpriority... yes
  checking for socket... yes
  checking what is the type of the third argument of getsockname... socklen_t
  checking what is the type of the fifth argument of getsockopt... socklen_t
  configure: WARNING: Dialup manager not supported on this platform... disabled
  checking for python... /Users/Dev/Projects/MyProjectName/.venv/bin/python3.9
  checking if AVKit is available... yes
  checking CXXWARNINGS for gcc -Woverloaded-virtual... -Woverloaded-virtual
  checking for a BSD-compatible install... /usr/bin/install -c
  checking for ranlib... ranlib
  checking whether ln -s works... yes
  checking whether make sets $(MAKE)... yes
  checking for ar... (cached) ar
  checking for strip... strip
  checking for nm... nm
  checking if make is GNU make... yes
  checking for gcc 3.1 or later... yes
  checking for dependency tracking method... gcc
  checking whether make sets $(MAKE)... (cached) yes
  checking whether catch.hpp file exists... yes
  === configuring in src/tiff (/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/build/wxbld/src/tiff)
  configure: running /bin/sh /private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/ext/wxWidgets/src/tiff/configure '--prefix=/usr/local' --disable-option-checking  '--enable-unicode' '--with-osx_cocoa' '--enable-sound' '--enable-graphics_ctx' '--enable-display' '--enable-geometry' '--enable-debug_flag' '--enable-optimise' '--disable-debugreport' '--enable-uiactionsim' '--enable-autoidman' '--with-macosx-version-min=10.10' '--disable-jbig' '--disable-webp' '--disable-zstd' '--disable-lzma' '--enable-jpeg' '--srcdir=/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/ext/wxWidgets/src/tiff' --cache-file=
  checking build system type... arm-apple-darwin21.1.0
  checking host system type... arm-apple-darwin21.1.0
  checking for a BSD-compatible install... /usr/bin/install -c
  checking whether build environment is sane... yes
  checking for a thread-safe mkdir -p... /private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/ext/wxWidgets/src/tiff/config/install-sh -c -d
  checking for gawk... no
  checking for mawk... no
  checking for nawk... no
  checking for awk... awk
  checking whether make sets $(MAKE)... yes
  checking whether make supports nested variables... yes
  checking how to create a pax tar archive... gnutar
  checking whether to enable maintainer-specific portions of Makefiles... no
  checking for gcc... gcc -mmacosx-version-min=10.10
  checking whether the C compiler works... yes
  checking for C compiler default output file name... a.out
  checking for suffix of executables...
  checking whether we are cross compiling... configure: error: in `/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/build/wxbld/src/tiff':
  configure: error: cannot run C compiled programs.
  If you meant to cross compile, use `--host'.
  See `config.log' for more details
  configure: error: /private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/ext/wxWidgets/src/tiff/configure failed for src/tiff
  Error running configure
  ERROR: failed building wxWidgets
  Traceback (most recent call last):
    File "/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/build.py", line 1510, in cmd_build_wx
      wxbuild.main(wxDir(), build_options)
    File "/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/buildtools/build_wxwidgets.py", line 372, in main
      exitIfError(wxBuilder.configure(dir=wxRootDir, options=configure_opts),
    File "/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-po537wqg/wxpython_412cc0ff52124d67bbc1dcd53926b02c/buildtools/build_wxwidgets.py", line 85, in exitIfError
      raise builder.BuildError(msg)
  buildtools.builder.BuildError: Error running configure
  Finished command: build_wx (0m23.434s)
  Finished command: build (0m23.434s)
  Command '"/Users/Dev/Projects/MyProjectName/.venv/bin/python3.9" -u build.py build' failed with exit code 1.
  ----------------------------------------
  ERROR: Failed building wheel for wxPython
  Running setup.py clean for wxPython
Failed to build wxPython

I have this same issue

me too; building this

There are not any universal or arm64 builds on PyPI yet. Also, there were incompatible changes made in newer MacOS SDKs that caused problems in the wxWidgets code used up to what we used for 4.1.1. So to do builds on newer SDKs we need a newer version of wxWidgets, and therefore a newer wxPython as well. You can get pre-release build for MacOS universal architectures from the snapshot builds, like this:

pip install --pre -f https://wxpython.org/Phoenix/snapshot-builds wxPython

However it looks like there is some issue with the newest wheel binaries there currently. I’ll work on fixing that, but in the meantime you can probably build a wheel using one of the source archives from the snapshot-builds folder. Something like this:

$ VERSION=4.1.2a1.dev5412+727f3aff

# Get the source archive
$ wget https://wxpython.org/Phoenix/snapshot-builds/wxPython-$VERSION.tar.gz

# Pull out the requirements files and install the listed packages into the 
# current Python venv
$ tar xzvf wxPython-$VERSION.tar.gz wxPython-$VERSION/requirements
$ pip install -U -r wxPython-$VERSION/requirements/devel.txt

# Now build a wheel file
$ pip wheel wxPython-$VERSION.tar.gz

Once you have that wheel file you can install it using pip in the venv or in other venvs.

Wow!!! this worked like a champ

This version is not existing anymore at that link. Which version should be used to install on MacOS 12.4?

Look in the snapshot-builds folder and find the newest version.

@Robin Thanks very much for this.
Also works on Windows
eg set VERSION=-4.1.2a1.dev5417+85aea3fd then replace $VERSION with %VERSION% in subsequent commands
works fine for -4.1.2a1.dev5417+85aea3fd
but not for
4.2.0a1.dev5449+3ac1e526
bw
john

Any timetable yet for a non daily build of 4.2?

Today. Or yesterday actually, I just finished building, uploading, announcing, etc. today.