whyour / qinglong

支持 Python3、JavaScript、Shell、Typescript 的定时任务管理平台(Timed task management platform supporting Python3, JavaScript, Shell, Typescript)
https://qinglong.online
Apache License 2.0
16.19k stars 2.98k forks source link

安装Python依赖报错:外部管理环境 #2503

Closed LuluDeer closed 1 month ago

LuluDeer commented 1 month ago

Qinglong version

正式版 v2.17.11

Steps to reproduce

Python所有依赖库无法正常安装,均报错失败

What is expected?

以前能正常安装Python全局依赖库运行同一个项目

What is actually happening?

现在重新部署了青龙拉项目后直接pip install xxx均报下面这种错误,非要给项目创建虚拟环境才给安装依赖 屏幕截图 2024-09-18 070917 或者只有带上pip install xxx --break-system-packages才能够正常安装依赖 屏幕截图 2024-09-18 070806

System Info

开始安装依赖 PyYAML,开始时间 2024-09-18 07:01:09

error: externally-managed-environment

× This environment is externally managed
╰─> 
    The system-wide python installation should be maintained using the system
    package manager (apk) only.

    If the package in question is not packaged already (and hence installable via
    "apk add py3-somepackage"), please consider installing it inside a virtual
    environment, e.g.:

    python3 -m venv /path/to/venv
    . /path/to/venv/bin/activate
    pip install mypackage

    To exit the virtual environment, run:

    deactivate

    The virtual environment is not deleted, and can be re-entered by re-sourcing
    the activate file.

    To automatically manage virtual environments, consider using pipx (from the
    pipx package).

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.

依赖安装失败,结束时间 2024-09-18 07:01:31,耗时 22 秒

Any additional comments?

已安装Python的Version: 3.12.6,后续可能有对应项目的虚拟环境管理功能,或者其他方法来处理这个情况吗?

whyour commented 1 month ago

python 不是用的 3.11 吗,你怎么安装的 3.12,demo 环境没有问题 http://demo.ninesix.cc:4433/

LuluDeer commented 1 month ago

python 不是用的 3.11 吗,你怎么安装的 3.12,demo 环境没有问题 http://demo.ninesix.cc:4433/

发现了我的alpine linux v3.20版本太新了,部署时运行apt add python3索引只有python3-3.12.6-r0.apk能装。而alpine linux v3.19才能安装和demo一样版本的python3-3.11.10-r0.apk,报错确实是python 3.12的新特性开启了 PEP 668 保护机制。降级alpine后部署运行正常了

whyour commented 1 month ago

https://www.cnblogs.com/amsilence/p/18427723 看文章删除相关文件即可