4

When trying to create new python 3.9 Virtualenv Environment in Pycharm I got such error

AttributeError: 'HTMLParser' object has no attribute 'unescape'


Traceback (most recent call last):
  File "/var/folders/6g/vnvmvlf51gv49m22rzj9zdtw0000gn/T/tmpifdsjw6lpycharm-management/setuptools-40.8.0/setup.py", line 11, in <module>
    import setuptools
  File "/private/var/folders/6g/vnvmvlf51gv49m22rzj9zdtw0000gn/T/tmpifdsjw6lpycharm-management/setuptools-40.8.0/setuptools/__init__.py", line 20, in <module>
    from setuptools.dist import Distribution, Feature
  File "/private/var/folders/6g/vnvmvlf51gv49m22rzj9zdtw0000gn/T/tmpifdsjw6lpycharm-management/setuptools-40.8.0/setuptools/dist.py", line 35, in <module>
    from setuptools.depends import Require
  File "/private/var/folders/6g/vnvmvlf51gv49m22rzj9zdtw0000gn/T/tmpifdsjw6lpycharm-management/setuptools-40.8.0/setuptools/depends.py", line 7, in <module>
    from .py33compat import Bytecode
  File "/private/var/folders/6g/vnvmvlf51gv49m22rzj9zdtw0000gn/T/tmpifdsjw6lpycharm-management/setuptools-40.8.0/setuptools/py33compat.py", line 55, in <module>
    unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
AttributeError: 'HTMLParser' object has no attribute 'unescape'

What can be done with it?

Gulzar
  • 10,451
  • 10
  • 52
  • 87
Headmaster
  • 1,260
  • 3
  • 16
  • 38
  • 1: Which version of PyCharm? 2: You might want to update setuptools. – Matthias Jan 01 '21 at 21:06
  • @Matthias - 1) 2019.2 2) Can you help me with this? Some instructions – Headmaster Jan 01 '21 at 21:17
  • A comment on this question https://stackoverflow.com/questions/17751439/htmlparser-htmlparser-unescape-doesnt-work says that it is `html.unescape` in Python 3. So it looks like you are trying to execute Python 2 code in a Python 3 environment. – BoarGules Jan 01 '21 at 21:22
  • 1
    It works for me with PyCharm 2020.3 and setuptools 51.1.1. In your console you can update setuptools with `pip install setuptools --upgrade`. – Matthias Jan 01 '21 at 21:33
  • @Matthias - thanks. I have to do both, update pycharm and setuptools. If you want, you can post an answer based on your comment, and I will accept it – Headmaster Jan 01 '21 at 21:41
  • I'm no point hunter. Having that as a comment is enough. :) – Matthias Jan 01 '21 at 22:13
  • Does this answer your question? [Why is 'pip3 install netifaces' failing on Debian 10 Buster?](https://stackoverflow.com/questions/65040971/why-is-pip3-install-netifaces-failing-on-debian-10-buster) – bad_coder Jan 02 '21 at 08:00
  • @bad_coder - actually, it affects some Pycharm settings. So, the link to the answer you've provided, does not fully answer my question – Headmaster Jan 02 '21 at 08:10
  • 1
    @Headmaster I googled the error, the removal of `HTMLParser().unescape` from Python 3.9 caused an incompatibility with a specific version of setuptools, that is resolved by upgrading the versions. There are countless scenarios where this error can occur but the cause and solution is always the same - upgrade to the latest versions. (But you are right, I'm retracting my close vote because in this case PyCharm itself needs to be updated.) – bad_coder Jan 02 '21 at 08:16

1 Answers1

3

Based on Matthias comment

To fix this error I have to update both pycharm (>=2020) and setuptools (>=41).

Hope this will help somebody

Headmaster
  • 1,260
  • 3
  • 16
  • 38