V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
abbyyhk
V2EX  ›  外包

求助 | 有偿 Python 项目部署支持

  •  
  •   abbyyhk · 4 天前 · 1058 次点击
    求助 | 有偿服务器部署支持

    我们正在部署一个 Python 网站,服务器环境 CentOS ,使用 Ansible + Poetry 进行自动化部署。目前卡在 Poetry 安装报错,尝试多种方法仍未解决。

    ✅ 已有 GitHub 项目
    项目地址: https://github.com/techlib/celus
    Ansible-Playbook: https://github.com/techlib/celus/blob/master/docs/ansible/roles/celus/tasks/main.yaml
    Line 28-56
    ✅ 阿里云服务器
    ✅ 愿意支付报酬,感谢技术支持!

    问题详情:Poetry 安装后,运行 poetry install 报错,可能与 Poetry 版本兼容性相关。

    📩 如果你有经验,或能提供解决方案,请联系!
    vx base64 cGFkemh1

    #Python #DevOps #Ansible #Poetry #服务器部署
    17 条回复    2025-03-17 11:41:52 +08:00
    crackidz
        1
    crackidz  
       4 天前
    有没有考虑过是 Python 版本问题...
    rooftop64
        2
    rooftop64  
       4 天前
    CentOS 版本、Python 版本?
    poetry install 报错信息?
    abbyyhk
        3
    abbyyhk  
    OP
       4 天前
    @crackidz python 版本是 3.6.8
    kylezb
        4
    kylezb  
       4 天前
    不是很懂,但是 34 行的 get-poetry.py 链接是 404 ,portry master 仓库里也没这个文件。
    xscanqianmeng666
        5
    xscanqianmeng666  
       4 天前
    为啥不用 docker
    abbyyhk
        6
    abbyyhk  
    OP
       4 天前
    @rooftop64 Ansible playbook:
    - name: check that poetry command exists
    stat: path=/root/.poetry/bin/poetry
    register: _poetry_executable

    - name: download the poetry installer
    get_url:
    url: https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
    dest: /tmp/get-poetry.py
    when: _poetry_executable.stat.exists == false

    - name: run the poetry installer
    command: /usr/bin/python3 /tmp/get-poetry.py -y
    when: _poetry_executable.stat.exists == false

    - name: install specific poetry version
    command: /root/.poetry/bin/poetry self update 1.1.8
    environment:
    VIRTUAL_ENV: /opt/virtualenvs/{{ project_name }}
    tags:
    - git_update

    - name: install project python dependencies using poetry
    environment:
    VIRTUAL_ENV: /opt/virtualenvs/{{ project_name }}
    command: /root/.poetry/bin/poetry install
    args:
    chdir: /opt/{{ project_name }}
    tags:
    - git_update

    Error msg:
    TASK [celus : install project python dependencies using poetry] *******************************************************************************************************
    fatal: [47.243.249.94]: FAILED! => {
    "changed": true,
    "cmd": ["/root/.poetry/bin/poetry", "install"],
    "delta": "0:00:00.770595",
    "end": "2025-03-13 09:09:32.128918",
    "msg": "non-zero return code",
    "rc": 1,
    "start": "2025-03-13 09:09:31.358323",
    "stderr": "
    RuntimeError

    The Poetry configuration is invalid:
    - Additional properties are not allowed ('package-mode' was unexpected)

    at ~/.poetry/venv/lib64/python3.6/site-packages/poetry/core/factory.py:45 in create_poetry
    41│ message = \"\"
    42│ for error in check_result[\"errors\"]:
    43│ message += \" - {}\\n\".format(error)
    44│
    → 45│ raise RuntimeError(\"The Poetry configuration is invalid:\\n\" + message)
    46│
    47│ # Load package
    48│ name = local_config[\"name\"]
    49│ version = local_config[\"version\"]
    ",
    "stderr_lines": [
    "",
    " RuntimeError",
    "",
    " The Poetry configuration is invalid:",
    " - Additional properties are not allowed ('package-mode' was unexpected)",
    " ",
    "",
    " at ~/.poetry/venv/lib64/python3.6/site-packages/poetry/core/factory.py:45 in create_poetry",
    " 41│ message = \"\"",
    " 42│ for error in check_result[\"errors\"]:",
    " 43│ message += \" - {}\\n\".format(error)",
    " 44│ ",
    " → 45│ raise RuntimeError(\"The Poetry configuration is invalid:\\n\" + message)",
    " 46│ ",
    " 47│ # Load package",
    " 48│ name = local_config[\"name\"]",
    " 49│ version = local_config[\"version\"]"
    ],
    "stdout": "",
    "stdout_lines": []
    }

    Poetry pyproject.toml
    https://github.com/techlib/celus/blob/master/pyproject.toml
    vicalloy
        7
    vicalloy  
       4 天前
    celus 这个项目要求的 python 版本是 3.8 ,你的 python 版本太老了。
    abbyyhk
        8
    abbyyhk  
    OP
       4 天前
    @kylezb 对,旧 Poetry 仓库失效了,这个地方需要改,但我不知道怎么改成新版的安装方式
    旧仓库: https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
    新:curl -sSL https://install.python-poetry.org | python3 -

    ref: https://python-poetry.org/docs/#installing-with-the-official-installer
    abbyyhk
        9
    abbyyhk  
    OP
       4 天前
    @rooftop64
    CentOS Alibaba Cloud Linux 3.2104 LTS 64 位
    Python 3.6.8
    rooftop64
        11
    rooftop64  
       4 天前
    安装的 poetry 版本多少?
    celus 版本没要求的话,可以用 https://github.com/techlib/celus/archive/refs/tags/v1.0.39.tar.gz 试下
    tomczhen
        12
    tomczhen  
       4 天前
    poetry1.x 版本应该是兼容的,可以试试装 1.8.5 这个版本试试。Python 版本没匹配上,可以试试下载 Python standalone 里面的静态编译包作为解释器省的再弄编译安装。
    abbyyhk
        13
    abbyyhk  
    OP
       4 天前
    @rooftop64 感谢大佬,我试下!
    robinlovemaggie
        14
    robinlovemaggie  
       4 天前
    @abbyyhk poetry 安装脚本过期了,换成这个:
    https://install.python-poetry.org/
    enrolls
        15
    enrolls  
       4 天前
    为什么用 Poetry 做环境管理呢?你要做环境管理,环境隔离,有很多替代方案,而不应该卡在“Poetry 安装报错”上。哪怕原生的 venv 都有方案,我自己在用,还没放工具出来。
    Martin123123
        16
    Martin123123  
       4 天前
    绿泡泡已联系
    defunct9
        17
    defunct9  
       19 小时 20 分钟前
    已解决。问题是很荒谬的。用 poetry 是根本不行的。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1154 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 205ms · UTC 23:02 · PVG 07:02 · LAX 16:02 · JFK 19:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.