Search code examples
pythonraspberry-pidebianwxpythonpython-3.11

wxPython install, attrdict dependency ModuleNotFound error


System Details:

  • Machine: Raspberry Pi Model 4B - 4GB
  • Operating System: Debian 11 (Bullseye)
  • wxPython version: 4.2.0 from pypi
  • Python version: 3.11.3 built from source

Problem Description:

When installing wxPython (latest version 4.2.0) I am getting an error that the attrdict dependency is not found, even though it is installed.

(.venv) user@raspberrypi:~/Documents $ python --version
Python 3.11.3

(.venv) user@raspberrypi:~/Documents $ python -m pip freeze
attrdict==2.0.1
attrdict3==2.0.2
dbus-fast==1.86.0
pytz==2023.3
six==1.16.0
tzdata==2023.3

(.venv) user@raspberrypi:~/Documents $ python -m pip install wxPython
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting wxPython
  Using cached wxPython-4.2.0.tar.gz (71.0 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
 
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      Traceback (most recent call last):
        File "/home/user/Documents/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/user/Documents/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/user/Documents/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-fs9i9itq/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-fs9i9itq/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-fs9i9itq/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 488, in run_setup
          self).run_setup(setup_script=setup_script)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-fs9i9itq/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 27, in <module>
        File "/tmp/pip-install-6s5ym1hn/wxpython_0afd12e3eb4741b4854a998e85194d91/buildtools/config.py", line 30, in <module>
          from attrdict import AttrDict
      ModuleNotFoundError: No module named 'attrdict'
      [end of output]
 
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

(.venv) user@raspberrypi:~/Documents $

Why is it saying that the dependency cannot be found when it is clearly there? Is there any way to correct this error and install wxPython on my system?

I have also opened an issue in the wxPython GitHub page: https://github.com/wxWidgets/Phoenix/issues/2401


Solution

  • By re-installing wheel and setuptools I was able to get it installed and working. I also removed attrdict and only installed attrdict3. So python -m pip uninstall attrdict attrdict3 wheel setuptools followed by python -m pip install -U wheel setuptools and then finally python -m pip install -U attrdict3.