pip安装出错解决一例(error: externally-managed-environment)

一、报错

pip install aliyundrive-fuse
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.

二、解决办法

按照上述提示,安装pipx

  1. 安装pipx

    api pipx
    The following NEW packages will be installed:
    blt{a} fonts-font-awesome{a} fonts-lato{a} ghp-import{a} libjs-bootstrap4{a} libjs-highlight.js{a} libjs-lunr{a} libjs-modernizr{a} 
    libjs-popper.js{a} libjs-sizzle{a} libtcl8.6{a} libtk8.6{a} mkdocs{a} node-jquery{a} pipx python3-argcomplete{a} python3-click{a} 
    python3-colorama{a} python3-dateutil{a} python3-iniconfig{a} python3-joblib{a} python3-livereload{a} python3-lunr{a} python3-markdown{a} 
    python3-mergedeep{a} python3-more-itertools{a} python3-nltk{a} python3-numpy{a} python3-packaging{a} python3-pip-whl{a} python3-pluggy{a} 
    python3-psutil{a} python3-py{a} python3-pytest{a} python3-pyyaml-env-tag{a} python3-regex{a} python3-setuptools-whl{a} 
    python3-simplejson{a} python3-tk{a} python3-tornado{a} python3-tqdm{a} python3-userpath{a} python3-venv{a} python3-watchdog{a} 
    python3.11-venv{a} sphinx-rtd-theme-common{a} tk8.6-blt2.5{a} 
    0 packages upgraded, 47 newly installed, 0 to remove and 2 not upgraded.
    Need to get 21.8 MB of archives. After unpacking 84.7 MB will be used.
    Do you want to continue? [Y/n/?] y
    Get: 1 http://mirrors.cloud.aliyuncs.com/debian bookworm/main amd64 fonts-lato all 2.0-2.1 [2,696 kB]
    Get: 2 http://mirrors.cloud.aliyuncs.com/debian bookworm/main amd64 libtcl8.6 amd64 8.6.13+dfsg-2 [1,035 kB]
    Get: 3 http://mirrors.cloud.aliyuncs.com/debian bookworm/main amd64 libtk8.6 amd64 8.6.13-2 [781 kB]
    
  2. 配置PATH

    pipx安装后,仍会有一个提示,需要配置PATH环境

pipx install aliyundrive-fuse
  installed package aliyundrive-fuse 0.1.14, installed using Python 3.11.2
  These apps are now globally available
    - aliyundrive-fuse
⚠️  Note: '/home/hotpod/.local/bin' is not on your PATH environment variable. These apps will not be globally accessible until your PATH is
    updated. Run `pipx ensurepath` to automatically add it, or manually modify your PATH in your shell's config file (i.e. ~/.bashrc).
done! ✨ 🌟 ✨
pipx ensurepath
Success! Added /home/hotpod/.local/bin to the PATH environment variable.

Consider adding shell completions for pipx. Run 'pipx completions' for instructions.

You will need to open a new terminal or re-login for the PATH changes to take effect.

Otherwise pipx is ready to go! ✨ 🌟 ✨
pipx completions

Add the appropriate command to your shell's config file
so that it is run on startup. You will likely have to restart
or re-login for the autocompletion to start working.

bash:
    eval "$(register-python-argcomplete pipx)"

zsh:
    To activate completions for zsh you need to have
    bashcompinit enabled in zsh:

    autoload -U bashcompinit
    bashcompinit

    Afterwards you can enable completion for pipx:

    eval "$(register-python-argcomplete pipx)"

tcsh:
    eval `register-python-argcomplete --shell tcsh pipx`

fish:
    # Not required to be in the config file, only run once
    register-python-argcomplete --shell fish pipx >~/.config/fish/completions/pipx.fish
eval "$(register-python-argcomplete pipx)"
  1. 查看.bashrc文件

    .bashrc文件末尾已经添加PATH

    # Created by `pipx` on 2023-12-09 00:03:37 
export PATH="$PATH:/home/hotpod/.local/bin"

results matching ""

    No results matching ""

    results matching ""

      No results matching ""