首页 > 编程问答 >我无法在 Debian Linux 中从命令行安装 Pyinstaller

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

时间:2024-07-31 09:54:06浏览次数:6  
标签:python pip debian apt

我想在我的 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 安装被外部管理,这在 Debian 上很可能是指 apt 包管理器。这意味着不应该使用 pip 来在全局安装 Python 包,因为这可能会导致冲突。

可以尝试以下两种解决方案:

1. 使用 venv 创建虚拟环境

这是推荐的方法,因为它将的项目依赖项与系统 Python 安装隔离开来。

  1. 创建一个新的虚拟环境: bash python3 -m venv myenv 这将在名为 myenv 的目录中创建一个新的虚拟环境。可以根据需要更改名称。

  2. 激活虚拟环境: bash source myenv/bin/activate

  3. 现在,可以在虚拟环境中使用 pip 安装 PyInstaller: bash pip install pyinstaller 这不会与的系统 Python 安装冲突。

    请记住,每次要处理此项目时,都需要激活虚拟环境。

2. 使用 pip 强制安装(不推荐)

如果确定要全局安装 PyInstaller 并且了解风险,则可以使用 --break-system-packages 标志来覆盖此错误:

bash sudo pip3 install pyinstaller --break-system-packages

但是,强烈建议不要这样做 ,因为它可能会导致的系统 Python 安装出现问题。 使用虚拟环境是更干净、更安全的选择。

标签:python,pip,debian,apt
From: 78814153

相关文章

  • Python - Composition
     classEngine:def__init__(self,power):self.power=powerdefstart(self):self.draw_current()self.spin()self.ignite()defdraw_current(self):print('Drawingcurrent')defspin(sel......
  • 为什么在使用 pip 警告:忽略无效的分发 -ip 时会收到此消息?
    在过去的几周里,每次我使用pip下载软件包时,我都会得到以下信息:警告:忽略无效的分发-ip(软件包路径)有什么想法为什么我会得到这个吗?看到「警告:忽略无效分发-ip」消息的原因是的Python软件包索引缓存中存在格式错误或损坏的文件。Pip在搜索软件包时发现这些文件无......
  • Python - Iterator vs Iterable
    Therearemanybuilt-infunctionsandmethodsthatreturniterablesanditerators.Hereareafewexamples:range()returnsaniterabledict.keys()returnsaniterabledict.items()returnsaniterabledict.values()returnsaniterableenumerate()returns......
  • 在python中使用变量引用Panda列名称
    我正在尝试编写一个函数来简化我的代码,因此我传递了包含列名称的变量。它适用于Django应用程序,调试器不会对我的错误所在提供任何反馈,只是“内部服务器错误”。我的代码工作正常,不是作为函数编写的:df_trips['trip_time_prep_starts']=df_trips["trip_time_prep_sta......
  • 如何在 Pyqt5 Python 中实现 QTableWidget 列过滤器中的搜索栏?
    我使用pyqt5创建了一个QTableWidget,并成功地在表格小部件的每一列中添加了过滤选项,并使用堆栈溢出上可用的答案之一。过滤器按预期工作,但我想在顶部的过滤器中添加搜索栏来搜索值。在我的python脚本中,过滤器中可能有大约50多个唯一值。因此,如果有一种方法可以在过滤器......
  • Python - Abstract Base classes
    Wehaveseenthatifwehavetodefineagroupofclassesthathavesimilarfeaturesandshowcommonbehavior,wecandefineabaseclassandtheninherittheclassesfromit.Inthederivedclasses,wehavethechoicetoeitherusethebaseclassversion......
  • Jenkins环境变量与构建工具 (pipeline)
     Jenkins内置变量pipeline{agentanystages{stage('mcwtest'){steps{echo"Running${env.BUILD_NUMBER}on${env.JENKINS_URL}"//方法一echo"Running$env.BUILD_NUMBERo......
  • python3 unittest+BeautifulReport单个进程输出多个测试报告
    最近一个项目中需要由于输出的案例内容非常多(上万条),导致BeautifulReport输出的报告内容非常大(几百兆)。浏览器无法正常处理这么大的测试报告,就算打开了,也不方便阅读和处理,因此需要将报告分成多个输出。经修改代码,发现单个进程内输出多个测试报告出现问题:第一个测试报告能正常数据......
  • 具有自引用的类装饰器的 Python 类型提示
    我的最终目标是编写一个系统来轻松记录函数调用(特别是类方法)。我首先编写一个带有包装方法的类Loggable,该方法允许我装饰子类方法并记录它们的调用|||现在我可以编写子类并记录它们的调用:Param=ParamSpec("Param")RetType=TypeVar("RetType")CountType=......
  • 如何在for循环中使用curve_fit函数在python中一次性创建多个回归?
    简而言之,我有两个矩阵,一个称为t,另一个称为y。每个都有7列。假设它们被称为a、b、c、d、e、f和g。我想要的是从a对a、b对b、...、g对g这两个矩阵进行回归。我已经设法使我的算法使用curve_fit对一列进行回归一次。但我真正希望的是它能够一次性完成7个回归......