每次使用 pip 3 时如何解决“错误:外部管理环境”?

2024-01-09

错误信息:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

我使用apt升级和更新。


你可以使用Python的venv就像描述的那样here https://stackoverflow.com/a/75696359/10626495.

但是,如果您确实想以这种方式安装软件包,那么有几种解决方案:

  • use pip的论点--break-system-packages,
  • 添加以下行到~/.config/pip/pip.conf:
[global]
break-system-packages = true
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

每次使用 pip 3 时如何解决“错误:外部管理环境”? 的相关文章

随机推荐