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

113 天前
 abbyyhk
求助 | 有偿服务器部署支持

我们正在部署一个 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 #服务器部署
1558 次点击
所在节点    外包
17 条回复
crackidz
113 天前
有没有考虑过是 Python 版本问题...
rooftop64
113 天前
CentOS 版本、Python 版本?
poetry install 报错信息?
abbyyhk
113 天前
@crackidz python 版本是 3.6.8
kylezb
113 天前
不是很懂,但是 34 行的 get-poetry.py 链接是 404 ,portry master 仓库里也没这个文件。
xscanqianmeng666
113 天前
为啥不用 docker
abbyyhk
113 天前
@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
113 天前
celus 这个项目要求的 python 版本是 3.8 ,你的 python 版本太老了。
abbyyhk
113 天前
@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
113 天前
@rooftop64
CentOS Alibaba Cloud Linux 3.2104 LTS 64 位
Python 3.6.8
clhlc
113 天前
rooftop64
113 天前
安装的 poetry 版本多少?
celus 版本没要求的话,可以用 https://github.com/techlib/celus/archive/refs/tags/v1.0.39.tar.gz 试下
tomczhen
113 天前
poetry1.x 版本应该是兼容的,可以试试装 1.8.5 这个版本试试。Python 版本没匹配上,可以试试下载 Python standalone 里面的静态编译包作为解释器省的再弄编译安装。
abbyyhk
113 天前
@rooftop64 感谢大佬,我试下!
robinlovemaggie
112 天前
@abbyyhk poetry 安装脚本过期了,换成这个:
https://install.python-poetry.org/
enrolls
112 天前
为什么用 Poetry 做环境管理呢?你要做环境管理,环境隔离,有很多替代方案,而不应该卡在“Poetry 安装报错”上。哪怕原生的 venv 都有方案,我自己在用,还没放工具出来。
Martin123123
112 天前
绿泡泡已联系
defunct9
109 天前
已解决。问题是很荒谬的。用 poetry 是根本不行的。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://ex.noerr.eu.org/t/1118006

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX