当前位置: 首页 > news >正文

解决Mac系统Python3.12版本pip安装报错error: externally-managed-environment的问题

遇到的问题

在Mac安装了Python3.12.x版本(3.12.3、3.12.4)后,当尝试pip3 install xxx的时候,总是报错:error: externally-managed-environment

error: externally-managed-environment× This environment is externally managed
╰─> To install Python packages system-wide, try brew installxyz, where xyz is the package you are trying toinstall.If you wish to install a Python library that isn't in Homebrew,use a virtual environment:python3 -m venv path/to/venvsource path/to/venv/bin/activatepython3 -m pip install xyzIf you wish to install a Python application that isn't in Homebrew,it may be easiest to use 'pipx install xyz', which will manage avirtual environment for you. You can install pipx withbrew install pipxYou may restore the old behavior of pip by passingthe '--break-system-packages' flag to pip, or by adding'break-system-packages = true' to your pip.conf file. The latterwill permanently disable this error.If you disable this error, we STRONGLY recommend that you additionallypass the '--user' flag to pip, or set 'user = true' in your pip.conffile. Failure to do this can result in a broken Homebrew installation.Read more about this behavior here: <https://peps.python.org/pep-0668/>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.

解决方法

通过which python3找到对应的目录,进入目录后,删除EXTERNALLY-MANAGED这个文件即可:

cd /usr/local/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12
rm -r EXTERNALLY-MANAGED

再次pip install xxx则不会再报错了。

http://www.lryc.cn/news/423411.html

相关文章:

  • lvm知识终结
  • ESP32S3 IDF 对 16路输入输出芯片MCP23017做了个简单的测试
  • 【技术前沿】Flux.1部署教程入门--Stable Diffusion团队最前沿、免费的开源AI图像生成器
  • Redis 的 STREAM 和 RocketMQ 是两种不同的消息队列和流处理解决方案,它们在设计理念、功能和用途上有显著区别。以下是它们的主要区别:
  • Visual Studio Code安装与C/C++语言运行(上)
  • 探索数据可视化,数据看板在各行业中的应用
  • haralyzer 半自动,一次性少量数据采集快捷方法
  • mall-admin-web-master前端项目下载依赖失败解决
  • 【07】JVM是怎么实现invokedynamic的
  • 使用API有效率地管理Dynadot域名,查看参与的拍卖列表
  • Linux 基本指令讲解
  • PRE_EMPHASIS
  • 【QT常用技术讲解】多线程处理+全局变量处理异步事件并获取多个线程返回的结果
  • 数组列表中的最大距离
  • C语言新手小白详细教程(7)指针和指针变量
  • Kafka保证消息不丢失
  • 数据结构+基数排序算法
  • C++ list【常用接口、模拟实现等】
  • 12.面试题——Spring Boot
  • 【前端VUE】npm i 出现版本错误等报错 简单直接解决命令
  • 精彩回顾 | 风丘科技亮相2024名古屋汽车工程博览会
  • 设计模式21-组合模式
  • 如何选择深度学习的损失函数和激活函数
  • DATAX自定义KafkaWriter
  • Mybatis分页多表多条件查询
  • SpringBoot快速入门(手动创建)
  • C 408—《数据结构》算法题基础篇—数组(通俗易懂)
  • AI秘境-墨小黑奇遇记 - 初体验(一)
  • 文件IO813
  • STP(生成树)的概述和工作原理