我无法在 Debian Linux 中从命令行安装 Pyinstaller

问题描述 投票:0回答:1

我想在我的 Debian 机器上安装 Pyinstaller,所以我运行了以下命令:

sudo pip3 install pyinstaller
这返回了以下错误:

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.

然后我运行了这个:

sudo apt install python3-pyinstaller
返回这个:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package python3-pyinstaller

我不知道还能尝试什么。 pip 一直在这样做,但通常使用 apt,我可以很容易地安装 Python 包。

python pip debian apt
1个回答
0
投票

正如错误消息所述,您需要通过 apt 进行全局安装,如果由于某种原因无法安装,那么下一个最好的办法就是将该软件包安装到某种虚拟环境中(例如使用

virtualenv env
然后
source env/bin/activate
激活虚拟环境)。就我而言,有一些软件包我绝对不会以任何其他方式安装,并且我希望能够在不激活任何虚拟环境的情况下使用它们(例如
bpytop
ps_mem
),所以就像错误所说的那样,直接通过
 --break-system-packages
当你跑步时
pip3 install pyinstaller
。为了澄清,该命令应如下所示:
pip3 install pyinstaller --break-system-packages

© www.soinside.com 2019 - 2024. All rights reserved.