Incompatible with Python 3.12

Trying to install wxPython via pip, it’s the pyenv version with Python 3.12.

➜  ~ which python
~/.pyenv/shims/python
➜  ~ python --version
Python 3.12.0

But obtained the following ERROR messages:

....
      copying /tmp/pip-install-_4fx4uwm/wxpython_71ce0814de1541c1b4f9035540efa799/build/wxbld/gtk3/lib/libwx_gtk3u_richtext-3.2.so.0 --> /tmp/pip-install-_4fx4uwm/wxpython_71ce0814de1541c1b4f9035540efa799/wx/libwx_gtk3u_richtext-3.2.so.0
      Running command: build_others
      ~/.pyenv/versions/latest/bin/python setup-wxsvg.py build_ext --inplace
      Compiling wx/svg/_nanosvg.pyx because it changed.
      [1/1] Cythonizing wx/svg/_nanosvg.pyx
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
      for manipulating the SVG shape info in memory.
      """
      
      import sys
      
      cimport cython.object
              ^
      ------------------------------------------------------------
      
      wx/svg/_nanosvg.pyx:45:8: 'cython.object' is not a valid cython.* module
      Traceback (most recent call last):
        File "/tmp/pip-install-_4fx4uwm/wxpython_71ce0814de1541c1b4f9035540efa799/setup-wxsvg.py", line 54, in <module>
          modules = cythonize([module],
                    ^^^^^^^^^^^^^^^^^^^
        File "~/.local/lib/python3.12/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
          cythonize_one(*args)
        File "~/.local/lib/python3.12/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
          raise CompileError(None, pyx_file)
      Cython.Compiler.Errors.CompileError: wx/svg/_nanosvg.pyx
      Command '~/.pyenv/versions/latest/bin/python setup-wxsvg.py build_ext --inplace' failed with exit code 1.
      Finished command: build_others (0.879s)
      Finished command: build_py (2m23.587s)
      Finished command: build (3m25.847s)
      Command '"~/.pyenv/versions/latest/bin/python" -u build.py build' failed with exit code 1.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for wxPython
  Running setup.py clean for wxPython
Failed to build wxPython
ERROR: Could not build wheels for wxPython, which is required to install pyproject.toml-based projects
➜  ~ 

Can anybody help? Thanks

In this case, the problem is not Python 3.12, but newer versions of Cython (version 3.0+). I’ve already fixed this in the git repo, but there hasn’t been a new release yet.

You could try pip install Cython == 0.29.37 and then try installing wxPython again as a workaround.

1 Like

Thank you very much… Problem solved…