【问题标题】:Why is 'pip3 install netifaces' failing on Debian 10 Buster?为什么 Debian 10 Buster 上的“pip3 install netifaces”失败?
【发布时间】:2021-04-08 08:32:39
【问题描述】:

我在 AWS EC2 上设置了一个新的 Debian 10 (Buster) 实例,并且能够安装一个依赖于 netifaces 的 pip3 包,但是当我第二天回到它时,该包在 netifaces 中报告错误。如果我尝试运行 pip3 install netifaces 我会得到同样的错误:

~$ pip3 install netifaces
Collecting netifaces
  Using cached https://files.pythonhosted.org/packages/0d/18/fd6e9c71a35b67a73160ec80a49da63d1eed2d2055054cc2995714949132/netifaces-0.10.9.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 20, in <module>
        from setuptools.dist import Distribution, Feature
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 35, 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 55, in <module>
        unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
    AttributeError: 'HTMLParser' object has no attribute 'unescape'

【问题讨论】:

    标签: pip debian python-netifaces


    【解决方案1】:

    HTMLParser().unescape 在 Python 3.9 中被移除。比较 the code in Python 3.8Python 3.9

    错误似乎是setuptools 中的错误。尝试升级setuptools。或者使用 Python 3.8。

    【讨论】:

    • 完美! pip3 install --upgrade setuptools 修复了一切。
    • 谢谢!我还必须升级pip 来解决问题:python3 -m pip install --upgrade setuptools pip
    【解决方案2】:

    我在 PyCharm 2018 中遇到了这个问题。除了上面提到的升级 setuptools 之外,我还必须升级到 PyCharm 2020.3.4 来解决这个问题。 PyCharm 问题跟踪器上的相关错误:https://youtrack.jetbrains.com/issue/PY-39579

    希望这可以帮助某人避免花费数小时尝试调试。

    【讨论】:

      【解决方案3】:

      我通过deb管理有python3.6和相关包。 辅助项目需要 python3.9 以及修复 pip 和 AttributeError: 'HTMLParser' object has no attribute 'unescape' 的解决方案 是为一个用户在本地更新 python3.9 的 pip:

      python3.9 -m pip install --upgrade pip
      

      现在安装python3.9版本的pip-packages工作:

      python3.9 -m pip install --target=~/.local/lib/python3.9/site-packages numpy
      

      【讨论】:

        【解决方案4】:

        降级到任何较旧的 python3 版本都不是解决方案,而且大多数时候升级 setuptools 不会解决问题。在 Ubuntu18 上,我使用 python3.9 使用 pip 的正确解决方案如下: 定位 /usr/lib/python3/dist-packages/setuptools/py33compact.py33 并改变

        # unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)  # comment out this line
        unescape = getattr(html, 'unescape', None)
        if unescape is None:
            # HTMLParser.unescape is deprecated since Python 3.4, and will be removed
            # from 3.9.
            unescape = html_parser.HTMLParser().unescape
        

        【讨论】:

          猜你喜欢
          • 2020-03-26
          • 1970-01-01
          • 1970-01-01
          • 2015-12-11
          • 1970-01-01
          • 2016-12-08
          • 1970-01-01
          • 2023-01-14
          • 1970-01-01
          相关资源
          最近更新 更多