Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attrdict a requirement for pip install fails otherwise. #2225

Closed
tatarize opened this issue Aug 9, 2022 · 44 comments
Closed

attrdict a requirement for pip install fails otherwise. #2225

tatarize opened this issue Aug 9, 2022 · 44 comments

Comments

@tatarize
Copy link

tatarize commented Aug 9, 2022

PS C:\Users\Tat\PycharmProjects\meerk40t> pip install wxPython
Collecting wxPython
  Downloading wxPython-4.2.0.tar.gz (71.0 MB)
     ---------------------------------------- 71.0/71.0 MB 735.6 kB/s eta 0:00:00
  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 "C:\Users\Tat\AppData\Local\Temp\pip-install-n4x9oroc\wxpython_3fcdd7a92a3246c686817597dd963d32\setup.py", line 27, in <module>
          from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
        File "C:\Users\Tat\AppData\Local\Temp\pip-install-n4x9oroc\wxpython_3fcdd7a92a3246c686817597dd963d32\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.

It fixed and installed after pip install attrdict but I don't usually expect failure to pip install.

@FreeHarry
Copy link
Contributor

It fixed and installed after pip install attrdict but I don't usually expect failure to pip install.

But with python 3.10 on my ArchLinux it is raising the following error:

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
  ╰─> [12 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-v2d0o325/wxpython_2d295bd40b8f4afcb9fdee5d09790f32/setup.py", line 27, in <module>
          from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
        File "/tmp/pip-install-v2d0o325/wxpython_2d295bd40b8f4afcb9fdee5d09790f32/buildtools/config.py", line 30, in <module>
          from attrdict import AttrDict
        File "/home/harry/.pyvenv/general/lib/python3.10/site-packages/attrdict/__init__.py", line 5, in <module>
          from attrdict.mapping import AttrMap
        File "/home/harry/.pyvenv/general/lib/python3.10/site-packages/attrdict/mapping.py", line 4, in <module>
          from collections import Mapping
      ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
      [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.

It seems that attrdict is incompatible with python 3.10. This is caused by a change in the collections interface starting with Python 3.10.

@swt2c
Copy link
Collaborator

swt2c commented Aug 9, 2022

You need attrdict3 not attrdict. Note that it is only actually used on Windows currently, so I submitted a PR to remove it on other platforms, see #2224

@tatarize
Copy link
Author

My linux unittest started failing due to that too. I sort of expect those kinks to get worked out. And the wheels really should have deployed I think for my OS but I'm not too worried since it bleeding edge.

@swt2c
Copy link
Collaborator

swt2c commented Aug 10, 2022

@tatarize, what is your OS and Python version?

@2sn
Copy link

2sn commented Aug 11, 2022

@swt2c installing attrdict3 works for me for now. Thanks.

@tatarize
Copy link
Author

@tatarize, what is your OS and Python version?

Windows 7. Python 3.8 but I also had unittest in linux fail along the same lines it was trying to install wxPython for a thing it didn't really need it for.

@Flanisch
Copy link

I had the same issue on arch linux recently. If for some reason older versions of wxPython with python 3.10 are needed, you can change the import occurrences of from collections to from collections.abc within the attrdict library.

@alexdewar
Copy link
Contributor

You need attrdict3 not attrdict. Note that it is only actually used on Windows currently, so I submitted a PR to remove it on other platforms, see #2224

It's not only used on Windows, hence why builds are now failing on Linux. At the very least, it is needed when the wheel is built from source (as it always is on Linux). I'm afraid I don't know the inner workings of wxpython better to narrow it down further.

Here is my pip error log:

  Command ['/home/alex/code/iPANACEA/.venv/bin/pip', 'install', '--no-deps', '-U', 'file:///home/alex/.cache/pypoetry/artifacts/82/c0/3a/d4a405db6cce1fdd910ba65dd2db32dcba675b4efec2e445f4140c6fa6/wxPython-4.2.0.tar.gz'] errored with the following return code 1, and output: 
  Processing /home/alex/.cache/pypoetry/artifacts/82/c0/3a/d4a405db6cce1fdd910ba65dd2db32dcba675b4efec2e445f4140c6fa6/wxPython-4.2.0.tar.gz
    Preparing metadata (setup.py): started
    Preparing metadata (setup.py): finished with status '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-req-build-oy_awq84/setup.py", line 27, in <module>
            from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
          File "/tmp/pip-req-build-oy_awq84/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

@swt2c
Copy link
Collaborator

swt2c commented Aug 23, 2022

There isn't any need to narrow it down further. You need to install attrdict3 in order to build wxPython 4.2.0. In the future, you'll only need it on Windows.

@tatarize
Copy link
Author

The objection I had was that Linux stopped working. I had some github Linux thing that required wx for unit tests and it threw that error. It didn't work in my windows7 python3.8 setup either since it demanded the attrdict thing.

With the merge of not requiring this for Linux this might be closable. I'm used to just getting a valid wheels for windows rather than it trying to compile the whole thing that it doesn't seem like it should have thrown that error at me there either. But, that might be fixable and the Windows10/Python 3.10 system had it install without issue.

@tatarize
Copy link
Author

I did just remove wx from the linux unittests since they were never used. So I might not be well versed on all the threads of this issue.

@alexdewar
Copy link
Contributor

There isn't any need to narrow it down further. You need to install attrdict3 in order to build wxPython 4.2.0. In the future, you'll only need it on Windows.

But the point is that you don't have a choice but to build it on Linux, so if you run pip install wxpython it currently just errors out. So on Linux it is a required dependency if you want users to be able to actually install wxpython.

@technout
Copy link

technout commented Aug 27, 2022

On Ubuntu 20.04.4 with kernel 5.15
Python 3.8 and wxPython 4.2.0

I got almost the same error:

$ pip3 install wxPython
Defaulting to user installation because normal site-packages is not writeable
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-n3c8k4cd/wxpython_e93e7db2517a413b9c0dc98d551d966a/setup.py", line 27, in <module>
          from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
        File "/tmp/pip-install-n3c8k4cd/wxpython_e93e7db2517a413b9c0dc98d551d966a/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.

Fixed it with: pip3 install attrdict

@forchtj
Copy link

forchtj commented Sep 1, 2022

I am getting the same error on CentOS 7.8.2003, python version 3.6.8, wxPython version 4.2.0.

Adding attrdict and/or attrdict3 to my requirements file ahead of wxpython does not solve the issue.

jmaibaum added a commit to jmaibaum/org.kicad.KiCad that referenced this issue Sep 1, 2022
@allenyllee
Copy link

allenyllee commented Sep 12, 2022

I am getting the same error on CentOS 7.8.2003, python version 3.6.8, wxPython version 4.2.0.

Adding attrdict and/or attrdict3 to my requirements file ahead of wxpython does not solve the issue.

@forchtj I have the same error on wine/windows, python version 3.6.8, wxPython version 4.2.0.

But when I downgrade to wxPython 4.1.1, the error was gone.

@alexdewar
Copy link
Contributor

Tbh I'm rather disappointed at the devs' lack of response here.

This breaks things for Linux users -- for example my CI is now failing for a number of projects and the only sensible fix is to pin wxpython to an older version. The offending commit should clearly just be reverted.

@swt2c
Copy link
Collaborator

swt2c commented Sep 16, 2022

Which offending commit?

@alexdewar
Copy link
Contributor

Thanks for your response! I think this is the one: 2e9169e

If I understand correctly, it removes attrdict3 as a dev dependency for Linux, meaning building wxpython (e.g. when you run pip install wxpython) will fail due to a missing import.

@swt2c
Copy link
Collaborator

swt2c commented Sep 16, 2022

No, sorry - that FIXES the problem you're seeing.

As a workaround for your CI, you can 'pip install attrdict3' before trying to install wxpython.

@alexdewar
Copy link
Contributor

So just to be clear, the intention of wxpython's developers is that pip install wxpython should be guaranteed to fail on Linux unless they execute another command beforehand?! That's a pretty user-hostile design 😞

What's so important about that commit that it's worth breaking your users for?

@swt2c
Copy link
Collaborator

swt2c commented Sep 16, 2022

Sorry, but you're misunderstanding the problem. When you're running pip install wxpython what you're getting DOES NOT include that commit!

@greyltc
Copy link

greyltc commented Sep 23, 2022

I have the same problem today. I was expecting pip install wxpython to work. This comment matches my exact experience: #2225 (comment)

@greyltc
Copy link

greyltc commented Sep 23, 2022

I guess building the 4.2.0 release is broken under modern linuxes because of the attrdict module import. Deleting

from attrdict import AttrDict
seems to solve the problem for me and it looks like that's already been done in the main branch via 2e9169e
So those wanting to build 4.2.0 (the latest stable release as of this writing) need to either patch it before building or wait for a new release that rolls in the fix from 2e9169e.

@tatarize
Copy link
Author

tatarize commented Sep 23, 2022

I'm pretty sure the commit you cited is to fix the issue. What you actually want is the releases of 4.2.0-post1 with that commit in place. Such that installs in Linux are not strange and crashing. We need the pip version to actually work. We don't want to wait a year for that to happen.

@RobinD42
Copy link
Member

This issue has been mentioned on Discuss wxPython. There might be relevant details there:

https://discuss.wxpython.org/t/error-trying-to-pip-install/36381/2

@matthew-mcallister
Copy link

It's not possible to install projects that depend on wxPython through pipx due to this bug.

@alexdewar
Copy link
Contributor

I've currently got the version of wxpython in my pyproject.toml pinned to <4.2.0 as a workaround.

It's been an issue for more than six months now though 😞

@JessicaTegner
Copy link

JessicaTegner commented Apr 2, 2023

A fix that worked for me was.

Open "Developer Command Prompt for VS 2022"
pip install attrdict3
pip install requests
pip install wxpython (this took around 5-10 minutes on my computer because it builds everything from source)

@Dyrimon
Copy link

Dyrimon commented Apr 4, 2023

Hi, I've installed requests, attrdict and attrdict3 successfully. Still can't install wxpython.

pip3 install wxpython
Defaulting to user installation because normal site-packages is not writeable
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
  ╰─> [12 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-u1w8x75r/wxpython_d591bb26891e49d9b951f65e5e8a400b/setup.py", line 27, in <module>
          from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
        File "/tmp/pip-install-u1w8x75r/wxpython_d591bb26891e49d9b951f65e5e8a400b/buildtools/config.py", line 30, in <module>
          from attrdict import AttrDict
        File "/home/fedora/.local/lib/python3.11/site-packages/attrdict/__init__.py", line 5, in <module>
          from attrdict.mapping import AttrMap
        File "/home/fedora/.local/lib/python3.11/site-packages/attrdict/mapping.py", line 4, in <module>
          from collections import Mapping
      ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib64/python3.11/collections/__init__.py)
      [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.

@jmoraleda
Copy link
Contributor

i, I've installed requests, attrdict and attrdict3 successfully. Still can't install wxpython.

You need to uninstall attrdict and keep only attrdict3.
Both projects are the same, in the sense that they both create python package attrdict. So installing both projects will result in only one of them being loaded, in your case attrdict instead of attrdict3.

attrdict3 (https://github.com/pirofti/AttrDict3) is a forked version of the original attrdict project (https://github.com/bcj/AttrDict). The fork was created when the original project stopped being maintained. attrdict3 includes recent updates that allow it to work in more recent versions of python. In particular, the original project will not work with Python 3.10 and later because of changes in the collections library that happened in 3.10.

@jmoraleda
Copy link
Contributor

i, I've installed requests, attrdict and attrdict3 successfully. Still can't install wxpython.

You need to uninstall attrdict and keep only attrdict3.
Both projects are the same, in the sense that they both create python package attrdict. So installing both projects will result in only one of them being loaded, in your case attrdict instead of attrdict3.

attrdict3 (https://github.com/pirofti/AttrDict3) is a forked version of the original attrdict project (https://github.com/bcj/AttrDict). The fork was created when the original project stopped being maintained. attrdict3 includes recent updates that allow it to work in more recent versions of python. In particular, the original project will not work with Python 3.10 and later because of changes in the collections library that happened in 3.10. You can see a diff between both projects in bcj/AttrDict@master...pirofti:AttrDict3:master

@psp2008xxx
Copy link

I try all the solution on my testbed and also feed this result to chatgpt, but it also failed. My testbed os is centos 7, python version is 3.9.10. Does anyone solve this issue?

@psp2008xxx
Copy link

psp2008xxx commented Apr 20, 2023

pip list:
Package Version


attrdict 2.0.1
attrs 23.1.0
bcrypt 4.0.1
certifi 2022.12.7
cffi 1.15.1
charset-normalizer 3.1.0
cryptography 40.0.2
decorator 5.1.1
idna 3.4
jsonpath-ng 1.5.3
jsonschema 4.17.3
paramiko 3.1.0
pip 23.1
ply 3.11
pycparser 2.21
PyNaCl 1.5.0
pyrsistent 0.19.3
requests 2.28.2
robotframework 6.0.2
robotframework-jsonlibrary 0.5
robotframework-sshlibrary 3.8.0
scp 0.14.5
setuptools 67.6.1
six 1.16.0
urllib3 1.26.15

os-release:
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

python version:
Python 3.9.10

@oyvindln
Copy link

@swt2c Would it be possible to put a point/patch release with the dependency changed to attrdict3 on pip so we don't have to workaround this while waiting for the next version?

@swt2c
Copy link
Collaborator

swt2c commented May 1, 2023

@oyvindln unfortunately, I don't have permissions to create new releases, only @RobinD42 does. Really a more helpful solution would be for Robin to make new wheels for Python 3.11 and 32-bit Windows, which would solve most of these problems. Most people probably do not want to build wxPython from scratch, but just install it.

@tatarize
Copy link
Author

tatarize commented May 2, 2023

Yeah, I actually sort of expected a -Post1 release a while back. I think it's probably fixed but still is causing wxPython to fail kind of universally. I've had to tell more than a couple people to install with ==4.1.1 since it was a bit screwy to get around this thing.

@heiko-weber
Copy link

heiko-weber commented Jun 1, 2023

on my debian 12 system there were the "gtk+ dev" missing
the attrdict was just confusing

sudo apt-get install build-essential libgtk-3-dev
found here -> #1831

some other issues seems to be to have wheel installed before.

@tatarize
Copy link
Author

With the release of wxPython 4.2.1, automatic installation is no longer failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests