10

After installing (ubuntu) python3.9, installing some packages with pip failes on:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 14, in <module>
        from setuptools.dist import Distribution, Feature
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 24, in <module>
        from setuptools.depends import Require
      File "/usr/lib/python3/dist-packages/setuptools/depends.py", line 7, in <module>
        from .py33compat import Bytecode
      File "/usr/lib/python3/dist-packages/setuptools/py33compat.py", line 54, in <module>
        unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
    AttributeError: 'HTMLParser' object has no attribute 'unescape'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
borgr
  • 9,229
  • 4
  • 18
  • 31
  • 1
    https://github.com/coursera-dl/coursera-dl/issues/778 https://github.com/coursera-dl/edx-dl/commit/5490a99a98b56f544661c131229ef640ace2b064 may help – leoleohu May 08 '21 at 03:57

1 Answers1

21

After some trial and error I upgraded, pip, distlib and setuptools and it solved it. Not sure which of those is causing it. (On the last two I found issues 1 2 of other sites) It is caused by removing unescape from HTMLParser in python3.9, which seems to break setuptools.

pip3 install --upgrade setuptools

If it does not work, try also:

pip3 install --upgrade pip
pip3 install --upgrade distlib
borgr
  • 9,229
  • 4
  • 18
  • 31
  • 1
    works for me! Either distlib or setuptools did it for me. – molecular Jan 10 '21 at 10:49
  • 2
    I tried this, I am using Pycharm IDE but still this is raising an error. I have updated pycharm , setuptools and distlib. What do I do now? – Ankita Gupta Mar 04 '21 at 14:12
  • Try running from the shell, is it possible you run from the wrong environment in pycharm? So it is not really updated? – borgr Mar 05 '21 at 15:45