【问题标题】:How to build a Python project for a specific version of Python?如何为特定版本的 Python 构建 Python 项目?
【发布时间】:2023-02-15 21:47:01
【问题描述】:

我有一个要部署到 AWS Lambda 的应用程序,因此它必须具有 Python 3.9。

我在 pyproject.toml 中有以下内容:

name = "app"
readme = "README.md"
requires-python = "<=3.9"
version = "0.5.4"

如果我尝试 pip 安装所有依赖项,我会收到以下错误:

ERROR: Package 'app' requires a different Python: 3.11.1 not in '<=3.9'

有没有办法为这个模块指定 Python 版本?

【问题讨论】:

标签: python


【解决方案1】:

您可以通过将以下部分添加到您的 pyproject.toml 文件来为您的模块指定 Python 版本:

[tool.poetry.dependencies]
python = "^3.9"

这指定您的应用程序需要 Python 3.9,Poetry 将确保您安装的任何依赖项都与该版本兼容。

添加此部分后,您可以运行poetry install 来安装具有正确 Python 版本的依赖项。

【讨论】:

    猜你喜欢
    • 2022-11-24
    • 1970-01-01
    • 2011-12-04
    • 1970-01-01
    • 2018-07-02
    • 1970-01-01
    • 1970-01-01
    • 2016-12-06
    • 2020-03-27
    相关资源
    最近更新 更多