wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.22k stars 509 forks source link

wxPython install dependency error attrdict ModuleNotFound #2401

Closed brennecj closed 1 year ago

brennecj commented 1 year ago

System Details:

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 $
swt2c commented 1 year ago

Try re-creating your venv, but dont install attrdict. You want attrdict3 not attrdict. You've got both installed.

brennecj commented 1 year ago

It looks like it's still showing the same error after removing attrdict. Also I uninstalled attrdict with pip uninstall attrdict instead of recreating the venv, but it should work the same.

(.venv) user@raspberrypi:~/Documents $ pip freeze
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-wnfxkp12/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-wnfxkp12/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-wnfxkp12/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-wnfxkp12/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-7p95zmbt/wxpython_d208b15ed61c43a988603ab08d950c7a/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 $ 
swt2c commented 1 year ago

It looks like it's still showing the same error after removing attrdict. Also I uninstalled attrdict with pip uninstall attrdict instead of recreating the venv, but it should work the same.

Should but might not. Please try re-creating venv.

brennecj commented 1 year ago

Alright I recreated the venv and it's still showing the same error:

(.new_venv) user@raspberrypi:~/Documents $ python -m pip freeze
attrdict3==2.0.2
six==1.16.0

(.new_venv) user@raspberrypi:~/Documents $ python -m pip install attrdict3
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting attrdict3
  Using cached https://www.piwheels.org/simple/attrdict3/attrdict3-2.0.2-py2.py3-none-any.whl (12 kB)
Collecting six (from attrdict3)
  Using cached https://www.piwheels.org/simple/six/six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: six, attrdict3
Successfully installed attrdict3-2.0.2 six-1.16.0
(.new_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/.new_venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/user/Documents/.new_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/.new_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-tldnax8p/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-tldnax8p/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-tldnax8p/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-tldnax8p/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-wz4czv5s/wxpython_9d8cca71f90547f9ac61874f947a1068/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.

(.new_venv) user@raspberrypi:~/Documents $ 
swt2c commented 1 year ago

Thanks for humoring me.

If you just run python in that venv, what happens if you just run: from attrdict import AttrDict ?

Also, what versions of pip and setuptools?

brennecj commented 1 year ago

It looks like python is able to import attrdict just fine. Version 23.1.2 of pip Version 65.5.0 of setuptools

(.new_venv) user@raspberrypi:~/Documents $ python -m pip freeze
attrdict3==2.0.2
six==1.16.0

(.new_venv) user@raspberrypi:~/Documents $ python
Python 3.11.3 (main, May 24 2023, 03:52:20) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from attrdict import AttrDict
>>> AttrDict()
AttrDict({})
>>> exit()

(.new_venv) user@raspberrypi:~/Documents $ python -m pip --version
pip 23.1.2 from /home/user/Documents/.new_venv/lib/python3.11/site-packages/pip (python 3.11)

(.new_venv) user@raspberrypi:~/Documents $ python -m pip show setuptools
Name: setuptools
Version: 65.5.0
Summary: Easily download, build, install, upgrade, and uninstall Python packages
Home-page: https://github.com/pypa/setuptools
Author: Python Packaging Authority
Author-email: [distutils-sig@python.org](mailto:distutils-sig@python.org)
License:
Location: /home/user/Documents/.new_venv/lib/python3.11/site-packages
Requires:
Required-by:

(.new_venv) user@raspberrypi:~/Documents $
swt2c commented 1 year ago

That's really strange. Can you try updating setuptools and see if that helps?

brennecj commented 1 year ago

Updated setuptools to the latest version (67.8.0), same result:

(.new_venv) user@raspberrypi:~/Documents $ python -m pip install --upgrade setuptools
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: setuptools in ./.new_venv/lib/python3.11/site-packages (65.5.0)
Collecting setuptools
  Using cached https://www.piwheels.org/simple/setuptools/setuptools-67.8.0-py3-none-any.whl (1.1 MB)
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 65.5.0
    Uninstalling setuptools-65.5.0:
      Successfully uninstalled setuptools-65.5.0
Successfully installed setuptools-67.8.0

(.new_venv) user@raspberrypi:~/Documents $ python -m pip freeze
attrdict3==2.0.2
six==1.16.0

(.new_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/.new_venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/user/Documents/.new_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/.new_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-_y61ehpw/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-_y61ehpw/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-_y61ehpw/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-_y61ehpw/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-tto1qfr2/wxpython_d6dd5ec43b4c4a53915c4f91de76536b/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.

(.new_venv) user@raspberrypi:~/Documents $ 
brennecj commented 1 year ago

It seems like this issue is similar to issue 2225 as well

swt2c commented 1 year ago

This particular issue seems to be related to pip 23.1.2 or thereabouts. I'm able to reproduce the problem. If you downgrade to 22.3.1, it seems to work.

swt2c commented 1 year ago

Er, actually, pip install wheel seems to fix the problem also, even with pip 23.1.2.

brennecj commented 1 year ago

Awesome, that worked, thanks so much! It said that wheel was already installed, so I just did a pip uninstall wheel and then reinstalled it with pip install -U wheel. I also did the same for setuptools. Thanks again for figuring that out! I'm not really sure why re-installing wheel and setuptools fixed it, but I'm glad that I could get it installed!

brennecj commented 1 year ago

Actually, it looks like that wasn't the root cause. I tried to install wxPython in another venv following the same steps (install only attrdict3, reinstall wheel and setuptools) and I am still getting the same error:

user@raspberrypi:~/Documents $ source .venv/bin/activate

(.venv) user@raspberrypi:~/Documents $ python -m pip freeze
aioconsole==0.6.1
attrdict3==2.0.2
bleak==0.20.2
dbus-fast==1.86.0
numpy==1.24.3
pandas==2.0.2
Pillow==9.5.0
psutil==5.9.5
python-dateutil==2.8.2
pytz==2023.3
PyYAML==6.0
RPi.GPIO==0.7.1
scipy==1.10.1
six==1.16.0
tzdata==2023.3

(.venv) user@raspberrypi:~/Documents $ python -m pip install -U pip
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pip in ./.venv/lib/python3.11/site-packages (23.1.2)

(.venv) user@raspberrypi:~/Documents $ python -m pip uninstall wheel setuptools
WARNING: Skipping wheel as it is not installed.
Found existing installation: setuptools 65.5.0
Uninstalling setuptools-65.5.0:
  Would remove:
    /home/user/Documents/.venv/lib/python3.11/site-packages/_distutils_hack/*
    /home/user/Documents/.venv/lib/python3.11/site-packages/distutils-precedence.pth
    /home/user/Documents/.venv/lib/python3.11/site-packages/pkg_resources/*
    /home/user/Documents/.venv/lib/python3.11/site-packages/setuptools-65.5.0.dist-info/*
    /home/user/Documents/.venv/lib/python3.11/site-packages/setuptools/*
Proceed (Y/n)? Y
  Successfully uninstalled setuptools-65.5.0

(.venv) user@raspberrypi:~/Documents $ python -m pip install -U wheel setuptools
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting wheel
  Using cached https://www.piwheels.org/simple/wheel/wheel-0.40.0-py3-none-any.whl (64 kB)
Collecting setuptools
  Using cached https://www.piwheels.org/simple/setuptools/setuptools-67.8.0-py3-none-any.whl (1.1 MB)
Installing collected packages: wheel, setuptools
Successfully installed setuptools-67.8.0 wheel-0.40.0

(.venv) user@raspberrypi:~/Documents $ python -m pip install -U 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)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-t06fz7xn/wxpython_4c197dbf116c40cc917168d899241e90/setup.py", line 27, in <module>
          from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
        File "/tmp/pip-install-t06fz7xn/wxpython_4c197dbf116c40cc917168d899241e90/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: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

(.venv) user@raspberrypi:~/Documents $ python -m pip freeze --all
aioconsole==0.6.1
attrdict3==2.0.2
bleak==0.20.2
dbus-fast==1.86.0
numpy==1.24.3
pandas==2.0.2
Pillow==9.5.0
pip==23.1.2
psutil==5.9.5
python-dateutil==2.8.2
pytz==2023.3
PyYAML==6.0
RPi.GPIO==0.7.1
scipy==1.10.1
setuptools==67.8.0
six==1.16.0
tzdata==2023.3
wheel==0.40.0

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

In the other venv (.new_venv) where I got the installation to work, I tried to install wxPython version 4.1.1 from source before I tried the wheel / setuptools reinstallation. The installation failed though, but perhaps something that happened during that installation fixed the error that we are seeing here?

brennecj commented 1 year ago

Also, in this venv, I am seeing some more weird behavior with attrdict:

(.venv) user@raspberrypi:~/Documents $ python -m pip freeze
aioconsole==0.6.1
attrdict3==2.0.2
bleak==0.20.2
dbus-fast==1.86.0
numpy==1.24.3
pandas==2.0.2
Pillow==9.5.0
psutil==5.9.5
python-dateutil==2.8.2
pytz==2023.3
PyYAML==6.0
RPi.GPIO==0.7.1
scipy==1.10.1
six==1.16.0
tzdata==2023.3

(.venv) user@raspberrypi:~/Documents $ python
Python 3.11.3 (main, May 24 2023, 03:52:20) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from attrdict import AttrDict
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'attrdict'
>>> exit()

(.venv) user@raspberrypi:~/Documents $ 
brennecj commented 1 year ago

It looks like uninstalling and reinstalling attrdict3 seems to have done the trick! So the solution is to:

  1. install / update wheel and setuptools (pip install -U wheel setuptools)
  2. reinstall attrdict3 (pip uninstall attrdict attrdict3 followed by pip install -U attrdict3)
heiko-weber commented 12 months ago

today I was playing with a new installed debian 12 with python 3.11.2, I had to pip install wheel before pip install wxPython

than it works, with a requirement.txt it was not working well

aiofiles 23.1.0 anyio 3.7.0 asyncio 3.4.3 attrdict3 2.0.2 Cerberus 1.3.4 certifi 2023.5.7 h11 0.14.0 httpcore 0.17.2 httpx 0.24.1 idna 3.4 numpy 1.24.3 Pillow 9.5.0 pip 23.1.2 setuptools 67.8.0 six 1.16.0 sniffio 1.3.0 wheel 0.40.0 wxasync 0.49 wxPython 4.2.0