wxPython not installing via PIP on Apple Silicon M1 Max

Have a project that is written in Python 3.8.x and wxPython. It was developed on an Apple MacBookPro (Intel-based). wxPython installed via PIP inside a virtual environment without problems. Life was good.

Then I get a new Apple MacBookPro (M1 Apple Silicon / ARM) based system. Installed Python3 via Homebrew, created project space and a new virtual environment via python3 -m venv .venv. The IDE of choice is Visual Studio Code (VSCode) with the Python plugin installed.

When running the following command in VSCode with the active virtual environment .venv for the project workspace, I see errors like:

configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

What is the ā€œuse ā€˜ā€“hostā€™ā€ referring to? The pip command when installing wxPython or some internal C compiler setting?

Here is the full error trace when running pip install -U wxPython inside the .venv environment on a Apple Silicon M1 system:

(.venv) system@local MyProjectName % pip 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.8/site-packages (from wxPython) (8.4.0)
Requirement already satisfied: six in ./.venv/lib/python3.8/site-packages (from wxPython) (1.16.0)
Requirement already satisfied: numpy in ./.venv/lib/python3.8/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' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/setup.py'"'"'; __file__='"'"'/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/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-8jjcyj2e
       cwd: /private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/
  Complete output (260 lines):
  /Users/Dev/Projects/MyProjectName/.venv/lib/python3.8/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.8/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" -u build.py build
  Will build using: "/Users/Dev/Projects/MyProjectName/.venv/bin/python3"
  3.8.9 (default, Aug  3 2021, 19:21:54)
  [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-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/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... no
  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
  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-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/build/wxbld/src/tiff)
  configure: running /bin/sh /private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/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-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/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-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/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-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/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-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/ext/wxWidgets/src/tiff/configure failed for src/tiff
  Error running configure
  ERROR: failed building wxWidgets
  Traceback (most recent call last):
    File "build.py", line 1510, in cmd_build_wx
      wxbuild.main(wxDir(), build_options)
    File "/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/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-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/buildtools/build_wxwidgets.py", line 85, in exitIfError
      raise builder.BuildError(msg)
  buildtools.builder.BuildError: Error running configure
  Finished command: build_wx (0m23.44s)
  Finished command: build (0m23.44s)
  Command '"/Users/Dev/Projects/MyProjectName/.venv/bin/python3" -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
Installing collected packages: wxPython
    Running setup.py install for wxPython ... error
    ERROR: Command errored out with exit status 1:
     command: '/Users/Dev/Projects/MyProjectName/.venv/bin/python3' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/setup.py'"'"'; __file__='"'"'/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/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'"'"'))' install --record /private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-record-hu50wtrm/install-record.txt --single-version-externally-managed --compile --install-headers '/Users/Dev/Projects/MyProjectName/.venv/include/site/python3.8/wxPython'
         cwd: /private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/
    Complete output (50 lines):
    /Users/Dev/Projects/MyProjectName/.venv/lib/python3.8/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.8/site-packages/setuptools/dist.py:294: DistDeprecationWarning: use_2to3 is ignored.
      warnings.warn(f"{attr} is ignored.", DistDeprecationWarning)
    running install
    /Users/Dev/Projects/MyProjectName/.venv/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    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" -u build.py build
    Will build using: "/Users/Dev/Projects/MyProjectName/.venv/bin/python3"
    3.8.9 (default, Aug  3 2021, 19:21:54)
    [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-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/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... configure: error: in `/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/build/wxbld':
    configure: error: cannot run C compiled programs.
    If you meant to cross compile, use `--host'.
    See `config.log' for more details
    Error running configure
    ERROR: failed building wxWidgets
    Traceback (most recent call last):
      File "build.py", line 1510, in cmd_build_wx
        wxbuild.main(wxDir(), build_options)
      File "/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/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-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/buildtools/build_wxwidgets.py", line 85, in exitIfError
        raise builder.BuildError(msg)
    buildtools.builder.BuildError: Error running configure
    Finished command: build_wx (0m5.814s)
    Finished command: build (0m5.814s)
    Command '"/Users/Dev/Projects/MyProjectName/.venv/bin/python3" -u build.py build' failed with exit code 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: '/Users/Dev/Projects/MyProjectName/.venv/bin/python3' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/setup.py'"'"'; __file__='"'"'/private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-install-jm73uoks/wxpython_2050e380cbcf449482f47c041513b558/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'"'"'))' install --record /private/var/folders/n_/9br5lnpx1r3bd6p_k4v5s1v40000gn/T/pip-record-hu50wtrm/install-record.txt --single-version-externally-managed --compile --install-headers '/Users/Dev/Projects/MyProjectName/.venv/include/site/python3.8/wxPython' Check the logs for full command output.

I am stuck and all my reading on the wxPython webpage, didnā€™t really point me to any solutions.

My questions are:

  • Are these errors the result of wxPython 4.1.1 not compatible with Apple Silicon M1 platforms? Is anyone successfully running wxPython within a .venv setup?
  • Are these errors the result of missing librarys that I need to install via Homebrew on the host itself, outside the .venv?
  • Are these errors the result of missing python extensions within the .venv that wxPython requires to compile/build?
1 Like

Presumably because the last release of wxPython was quite a while ago (Nov 2020 - over a year ago now) and there is nothing uploaded to PyPI that supports M1.

Christmas is coming so hopefully Santa is going to come :wink:

@cybercitizen443: Did you find any solution to the issue?

Any update on this? Unfortunately Santa forgot us @Brendan_Simon_eTRIX

Although Iā€™m not an expert on Python, I tried to build the library by myself (python 3.8.11 using pyenv) but also had no luck. I followed this guide https://wxpython.org/blog/2017-08-17-builds-for-linux-with-pip/index.html to build version 4.0.7-post2 (because itā€™s the dependency I need to install robotframework-ride package) and also 4.1.1, but no luckā€¦

On M1 I couldnā€™t install via pip too, but conda can install. Activate your venv and then install via conda:

conda activate myvenv

conda install wxPython

I am having the same problem, installing WxPython on an M1 MacBook Pro. I tried to post the listing of my unsuccessful attempt. But I got a message that as a new user I could not post more than 2 links. But I have no idea what qualifies as link, so I couldnā€™t demonstrate my problem.

Any updates? Wanted to give a +1 to the issue - I am unable to build wxPython on my Apple M1 Silicon using pip or conda

1 Like

+1 Also having this issue! No matter which environment Iā€™m in I canā€™t seem to install on any silicon Mac.

This works for me:

export CFLAGS=-I/$(brew --prefix)/include
export CXXFLAGS=-I/$(brew --prefix)/include
pip install wxPython

I tried the flags, no go for me. :frowning:

Hi,
Any update regarding this case?
I fount this solution:
https://discuss.wxpython.org/t/failed-building-wheel-for-wxpython-macos-12-0-1/35700/4
but i think this version not stable.
Thanks

Currently using a snapshot build is the only option for getting a universal (multi-architecture) build for macOS.

Thanks @Robin , I am on Macbook Pro M1 Pro, Python 3.10, using Pycharm. I am only able to install wxpython via this command:

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

Which downloads and installs ā€˜wxPython-4.2.0a1.dev5449%2B3ac1e526-cp39-cp39-macosx_10_10_universal2.whlā€™. This works, BUTā€¦ I have random behaviour with drag and drop, most of the time it doesnt work. When dropping a file, neither ā€˜setSubmissionDropā€™ is not called. Here is a sample which does work correctly everytime on Linux, but not on Mac:

import wx
import wx.lib.newevent
drop_event, EVT_DROP_EVENT = wx.lib.newevent.NewEvent()

class ScrolledWindow(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(510, 330), style=wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER |
                                                wx.MAXIMIZE_BOX))

        run_params = {}
        self.tabbed = wx.Notebook(self, -1, style=(wx.NB_TOP))
        self.filePrep = PrepFile(self.tabbed, self, run_params)
        self.fileCheck = CheckFile(self.tabbed, self, run_params)

        self.tabbed.AddPage(self.filePrep, "File Prep")
        self.tabbed.AddPage(self.fileCheck, "File Check")
        self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.switchSize)

        self.Centre()
        self.Show()

    def switchSize(self, e):
        page = self.tabbed.GetPageText(self.tabbed.GetSelection())
        if page == 'File Prep':
            self.SetSize((510, 330))
        elif page == 'File Check':
            self.SetSize((510, 510))

class PrepFile(wx.Panel):
    def __init__(self, parent, frame, run_params):
        wx.Panel.__init__(self, parent)
        self.run_params = run_params
        self.parent = parent
        self.frame = self
        self.selectedFiles = ""

        outputtxt3 = '''Drag and Drop files'''
        wx.StaticText(self, -1, outputtxt3, pos=(25, 180), style=wx.ALIGN_CENTRE)
        self.tc_files = wx.TextCtrl(self, wx.ID_ANY, pos=(28, 200), size=(360, 25))
        self.drop_target = MyFileDropTarget(self)
        self.tc_files.SetDropTarget(self.drop_target)
        self.Bind(EVT_DROP_EVENT, self.setSubmissionDrop)
        self.tc_files.SetFocus()
        self.Show()

    def setSubmissionDrop(self, event):
        """Called by the FileDropTarget when files are dropped"""
        files = event.data
        print("\nprep event", files)
        self.tc_files.SetValue(','.join(files))
        self.selectedFiles = files

class CheckFile(wx.Panel):
    def __init__(self, parent, frame, run_params):
        wx.Panel.__init__(self, parent)

        self.run_params = run_params
        self.parent = parent
        self.frame = self
        self.selectedFiles = ""

        wx.StaticText(self, -1, '''Drag and Drop files''', pos=(25, 10), style=wx.ALIGN_CENTRE)
        self.tc_files = wx.TextCtrl(self, wx.ID_ANY, pos=(25, 30), size=(302, 25))
        self.drop_target = MyFileDropTarget(self)
        self.tc_files.SetDropTarget(self.drop_target)
        self.Bind(EVT_DROP_EVENT, self.setSubmissionDrop)
        self.tc_files.SetFocus()
        self.Show()

    def setSubmissionDrop(self, event):
        """Called by the FileDropTarget when files are dropped"""
        files = event.data
        print("\ncheck event", files)
        self.tc_files.SetValue(','.join(files))
        self.selectedFiles = files

class MyFileDropTarget(wx.FileDropTarget):
    """"""
    def __init__(self, window):
        wx.FileDropTarget.__init__(self)
        self.obj = window

    def OnDropFiles(self, x, y, filenames):
        drp_evt = drop_event(data=filenames)
        wx.PostEvent(self.obj, drp_evt)
        return True

app = wx.App()
ScrolledWindow(None, -1, 'File Prep ')
app.MainLoop()

On macOS the native textctrl is handling the drop itself, so your DropTarget is not getting a chance to deal with the event. Iā€™m not sure if there is a way to tell it to not do that, but you set the drop target on the panel instead to get something that works similarly to what you are after.

Thank you @Robin, Iā€™m not sure I understand your suggestion, could you show me a simple example please?

My suggestion is to do self.SetDropTarget instead of self.tc_files.SetDropTarget. That will make the whole panel be the target instead of the text ctrl.

Great, thanks @Robin, that now works, but only when I ā€˜dontā€™ drag and drop into the wx.TextCtrl box. So, I drag & drop anywhere in the panel (except the wx.TextCtrl box), and all works correctly. I drag & drop into the wx.TextCtrl box, and nothing happens. Any tips oon how to prevent the user draging & dropping into the wx.TextCtrl box, as this would be the natural place?

Kind regards.