hint: See PEP 668 for the detailed specification.

出现 externally-managed-environment 错误的原因是你的操作系统或 Python 环境开启了 PEP 668 保护机制。即使你创建了新的 conda 虚拟环境,系统仍然标记该环境为“外部管理的”,不允许直接通过 pip 安装包。这是为了保护系统级的 Python 环境不被破坏。

解决方案:

1. 使用 --break-system-packages

你可以通过添加 --break-system-packages 参数强制 pip 安装包。这将绕过 PEP 668 保护机制,但要谨慎使用,因为可能会影响系统或虚拟环境的稳定性。

pip install pymilvus jina --break-system-packages
2. 使用 conda install 安装包

优先使用 conda 来安装包,这样不会触发 externally-managed-environment 错误。你可以尝试通过 conda-forge 频道来安装包:

conda install -c conda-forge pymilvus jina
3. 创建一个不受 PEP 668 管理的虚拟环境

你可以通过 venv 创建一个完全独立于系统管理的虚拟环境。这样做可以避开 PEP 668 机制。

# 创建 venv 虚拟环境
python3 -m venv myenv

# 激活虚拟环境
source myenv/bin/activate

# 安装所需包
pip install pymilvus jina

总结

  • 推荐做法:首先使用 conda-forge 来安装包。
  • 强制方式:使用 --break-system-packages 绕过保护机制。
  • 隔离方式:使用 venv 创建完全隔离的虚拟环境来避开系统保护。
lhj@raspberrypi:~ $ # 先卸载残留文件 pip uninstall scikit-learn -y # 使用清华镜像源加速安装 pip install scikit-learn -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade --force-reinstall 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. For more information visit http://rptl.io/venv 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. 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. For more information visit http://rptl.io/venv 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.
07-22
lhj@raspberrypi:~ $ # 先卸载现有版本 sudo pip3 uninstall -y numpy # 清理残留文件 sudo rm -rf /usr/local/lib/python3.*/dist-packages/numpy* # 使用 piwheels 源安装(树莓派专用预编译包) sudo pip3 install --no-cache-dir numpy --index-url https://www.piwheels.org/simple 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. For more information visit http://rptl.io/venv 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. 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. For more information visit http://rptl.io/venv 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.
最新发布
07-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MonkeyKing.sun

对你有帮助的话,可以打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值