首页 > 其他分享 >Troubleshooting ‘Externally Managed Environment’ Error in Debian 12 Pip3 Installation

Troubleshooting ‘Externally Managed Environment’ Error in Debian 12 Pip3 Installation

时间:2023-11-21 09:11:39浏览次数:29  
标签:Externally 12 Managed package flask EXTERNALLY Environment install error

https://medium.com/@kiena/troubleshooting-externally-managed-environment-error-in-debian-12-pip3-installation-439d62e5a970

 

When working with Python on Debian 12, you may encounter an error message regarding an ‘Externally Managed Environment’.

This error can hinder your use of pip3, the package installer for Python. Fortunately, there are several methods to troubleshoot and resolve this issue. In this guide, we will explore various approaches to fix the 'Externally Managed Environment' error and get pip3 back on track.

Error Encounter

Fix PIP using Apt

One straightforward way to address the ‘Externally Managed Environment’ error is by using the apt package manager to reinstall or update pip3. This can be done with the following command:

# you can change flask with other packages
sudo apt install python3-flask

Fix PIP by Creating a Virtual Environment (Recomendded)

Creating a virtual environment is a recommended method for isolating your Python projects and avoiding conflicts. To fix the ‘Externally Managed Environment’ error, you can create a virtual environment using the following steps:

# Install the Python3 venv package if not already installed
sudo apt install python3-venv

# Create a new virtual environment
python3 -m venv myenv

# Activate the virtual environment
source myenv/bin/activate

Then, install the package you want to pip install flask.

Fix PIP with PIPX

Pipx is a tool that helps you manage Python packages and provides an alternative to using sudo for package installations. follow these steps:

# Install pipx if not already installed
sudo apt install pipx

install pipx

# Ensure the local path for pipx
pipx ensurepath

ensurepath

# Use pipx to install flask or another package you need
pipx install flask

Install flask

# List all installed package
pipx list

# Run the package, here flask as example
pipx run flask run

Run flask

Fix Pip by Removing EXTERNALLY-MANAGED

If the error persists, you can try removing the EXTERNALLY-MANAGED file, which might be causing the issue. However, before you proceed, make sure to back up the file to a safe location. You can use the following command to back up the file to your ~/Project directory:

# If you want change the folder, change the /Project
sudo cp /usr/lib/python3.11/EXTERNALLY-MANAGED ~/Project/EXTERNALLY-MANAGED-BACKUP

# Remove EXTERNALLY-MANAGED file in your python library
sudo rm /usr/lib/python3.11/EXTERNALLY-MANAGED

Remove EXTERNALLY-MANAGED

Remember, removing system files should be approached with caution, and it’s always a good practice to back up before making any changes.

Conclusion

In this guide, we explored different methods to troubleshoot and fix the ‘Externally Managed Environment’ error in Debian 12 when working with pip3. By reinstalling or updating pip3 using apt, creating virtual environments, utilizing pipx, and cautiously removing the EXTERNALLY-MANAGED file, you can effectively resolve the error and continue seamless package management. These solutions empower you to navigate the challenges and ensure a smooth Python development experience on your Debian 12 system.

标签:Externally,12,Managed,package,flask,EXTERNALLY,Environment,install,error
From: https://www.cnblogs.com/ztguang/p/17845484.html

相关文章

  • LY1464 [ 20231112 NOIP 模拟赛 T4 ] 序列计数
    题意给定\(n,m\)。求:\(a_1+a_2+...+a_m=n\)\(1^{a_1}\times2^{a_2}\times...\timesm^{a_m}\equivx(\bmodm)\)对于\(x\in[1,m)\)满足上述条件的方案数。Sol注意到下面的式子等价于:\(1\times1\times1...\times2\times2...\time......
  • 20231120
    2023/11/20早上脑子转的不是很快啊1851F-LisaandtheMartians看到位运算+贪心+异或:想到字典树,就是一个改编版本的最大异或对可以证明当ai和aj的某一位2进制位不同是,x在这一位无论怎么取都不行。所以当遍历到一个ai值时,取字典树里面贪心的查一下和他最大相同的值是多少#i......
  • 12864 接线及代码
       #include<reg51.h>#include<intrins.h>#defineucharunsignedchar#defineuintunsignedintsbitCS=P2^7;//片选信号sbitSID=P2^6;//数据信号sbitSCLK=P2^5;//时钟信号sbitRST=P1^1;//复位信号sbitCH=P1^0;//并行、串行选择信号/******************......
  • 20231120
    运行flash文件真是一件难事,不如直接转化为mp4通过本次的实验也是学习到了html界面中如何运行swf文件,也是了解到了flash的流氓性。更加深刻的了解到了人机交互技术的重要性。     ......
  • 游戏性能超越i9-12900K!i5-14600K评测:可轻松超频到全核5.6GHz
    一、前言:2000元的甜点处理器此前,我们快科技首发测试了酷睿第14代i9-14900K处理器,这款处理器可以说是Intel7(10nm)制程的巅峰之作。但这块处理器不论功耗、还是价格都非普通玩家能够成承受,相比之下,这款i5-14600K更加符合大众的需求。酷睿第14代i5-14600K处理器基于Intel7制程......
  • 123. 买卖股票的最佳时机 III(难)
    目录题目动态规划题目给定一个数组,它的第i个元素是一支给定的股票在第i天的价格。设计一个算法来计算你所能获取的最大利润。你最多可以完成两笔交易。注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。示例1:输入:prices=[3,3,5,0,0,3,1,4]输出:6......
  • MIT18.06Linear Algebra 第12讲 图、网络、关联矩阵
    转载于:超详细MIT线性代数公开课笔记......
  • 20231120
    一个人在机房的第一天呢。早上朝会过后就来机房了,上午有一些人来机房里拿东西什么的,下午就完全是我一个人在机房了。机房很空旷,只有我一个人显得分外冷清,外面黑漆漆的,有点吓人。自己学习了一些有关多项式和生成函数的东西,有点累,脑子要炸了。不过学完之后真的觉得数学很奇妙......
  • Databend 开源周报第 120 期
    Databend是一款现代云数仓。专为弹性和高效设计,为您的大规模分析需求保驾护航。自由且开源。即刻体验云服务:https://app.databend.cn。What'sOnInDatabend探索Databend本周新进展,遇到更贴近你心意的Databend。使用自定义CONNECTION管理存储访问Databend现已提......
  • (RF) 用于物联网和工业应用的SKY66421-11、SKY66422-11前端模块,而SKY66121-11、SKY661
    一、用于LPWAN、LoRa、IoT和工业应用的860至930MHz射频前端模块1、SKY66421-11是一款高性能、高度集成的射频前端模块,专为LPWAN(支持LoRa®、SigFox和其他免执照频段技术)以及工作在860-930MHz频率范围内的高功率工业、科学、医疗(ISM)应用而设计。SKY66421-11具有完全匹配的50ΩT......