标签: python-poetry

使用 Conda + Poetry 有意义吗?

使用 Conda + Poetry 进行机器学习项目有意义吗?让我分享一下我(新手)的理解,请指正或赐教:

据我了解,CondaPoetry有不同的目的,但很大程度上是多余的:

  • Conda主要是一个环境管理器(实际上不一定是Python),但它也可以管理包和依赖项。
  • Poetry 主要是一个 Python 包管理器(例如pip的升级),但它也可以创建和管理 Python 环境(例如Pyenv的升级)。

我的想法是同时使用两者并划分它们的角色:让 Conda 担任环境管理器,让 Poetry 担任包管理器。我的推理是(听起来)Conda 最适合管理环境,可用于编译和安装非 python 包,尤其是 CUDA 驱动程序(用于 GPU 功能),而 Poetry 作为 Python 包管理器比 Conda 更强大。

通过在 Conda 环境中使用 Poetry,我成功地相当轻松地完成了这项工作。诀窍是不要使用 Poetry 来管理 Python 环境:我没有使用poetry shellor poetry run、 onlypoetry init等命令poetry install(激活 Conda 环境后)。

为了充分披露,我的environment.yml文件(针对Conda)如下所示:

name: N

channels:
  - defaults
  - conda-forge

dependencies:
  - python=3.9
  - cudatoolkit
  - cudnn
Run Code Online (Sandbox Code Playgroud)

我的诗歌.toml …

python machine-learning package conda python-poetry

163
推荐指数
2
解决办法
7万
查看次数

libssl.so.1.1:无法打开共享对象文件:没有这样的文件或目录

我刚刚更新到Ubuntu 22.04 LTS,我使用OpenSSL 的库刚刚停止工作。看起来 Ubuntu 已经切换到了 OpenSSL 3.0 版本。

例如,诗歌不再起作用:

Traceback (most recent call last):
  File "/home/robz/.local/bin/poetry", line 5, in <module>
    from poetry.console import main
  File "/home/robz/.local/share/pypoetry/venv/lib/python3.9/site-packages/poetry/console/__init__.py", line 1, in <module>
    from .application import Application
  File "/home/robz/.local/share/pypoetry/venv/lib/python3.9/site-packages/poetry/console/application.py", line 7, in <module>
    from .commands.about import AboutCommand
  File "/home/robz/.local/share/pypoetry/venv/lib/python3.9/site-packages/poetry/console/commands/__init__.py", line 4, in <module>
    from .check import CheckCommand
  File "/home/robz/.local/share/pypoetry/venv/lib/python3.9/site-packages/poetry/console/commands/check.py", line 2, in <module>
    from poetry.factory import Factory
  File "/home/robz/.local/share/pypoetry/venv/lib/python3.9/site-packages/poetry/factory.py", line 18, in <module>
    from .repositories.pypi_repository import …
Run Code Online (Sandbox Code Playgroud)

python linux openssl python-poetry

114
推荐指数
8
解决办法
22万
查看次数

如何在 pyproject.toml 的可编辑模式下使用 pip 安装包?

当一个项目仅通过via pyproject.toml(即没有文件)指定时setup.{py,cfg},如何以可编辑模式通过via pip(即python -m pip install -e .)安装它?

我尝试了setuptoolspoetry构建系统,但都不起作用:

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
Run Code Online (Sandbox Code Playgroud)
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Run Code Online (Sandbox Code Playgroud)

我在两个构建系统上都遇到相同的错误:

[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
Run Code Online (Sandbox Code Playgroud)

我在conda环境中使用它,以下是我的setuptools和版本pip

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Run Code Online (Sandbox Code Playgroud)

python pip setuptools python-poetry pyproject.toml

96
推荐指数
3
解决办法
5万
查看次数

在现有项目上安装诗歌错误“不包含任何元素”

我是第一次使用 Poetry。\n我有一个非常简单的项目。基本上

\n
a_project\n|\n|--test\n|    |---test_something.py\n|\n|-script_to_test.py\n
Run Code Online (Sandbox Code Playgroud)\n

从我做的一个项目poetry init开始poetry install

\n

我得到以下内容

\n
 poetry install\nUpdating dependencies\nResolving dependencies... (0.5s)\n\nWriting lock file\n\nPackage operations: 7 installs, 0 updates, 0 removals\n\n  \xe2\x80\xa2 Installing attrs (22.2.0)\n  \xe2\x80\xa2 Installing exceptiongroup (1.1.0)\n  \xe2\x80\xa2 Installing iniconfig (2.0.0)\n  \xe2\x80\xa2 Installing packaging (23.0)\n  \xe2\x80\xa2 Installing pluggy (1.0.0)\n  \xe2\x80\xa2 Installing tomli (2.0.1)\n  \xe2\x80\xa2 Installing pytest (7.2.1)\n\n/home/me/MyStudy/2023/pyenv_practice/dos/a_project/a_project does not contain any element\n
Run Code Online (Sandbox Code Playgroud)\n

之后我可以poetry run pytest毫无问题地运行,但是该错误消息是什么意思?

\n

python python-poetry

73
推荐指数
3
解决办法
4万
查看次数

使用 Pip 下载 pyproject.toml 中声明的依赖项

我有一个不包含requirements.txt. 但它有一个pyproject.toml文件。

如何下载此 Python 项目所需的包(依赖项)并使用pyproject.tomlPip 包管理器(而不是构建工具 Poetry)声明。

因此pip download -r requirements.txt,而不是类似的东西pip download -r pyproject.toml

python pip python-poetry pyproject.toml

68
推荐指数
3
解决办法
5万
查看次数

已安装 Poetry 但“poetry:未找到命令”

最近我在诗歌方面遇到了一百万零一个问题。

我昨天已经完全安装并工作了,但是重新启动我的机器后,我又遇到了问题;(

即使在重新启动后,是否有办法在我的终端中始终识别诗歌?


系统规格:

  • Windows 10,
  • Visual Studio 代码,
  • Bash - WSL Ubuntu CLI,
  • Python 3.8。

终端:

me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/workers-python/workers/data_simulator/src$ poetry run python3 cli.py
poetry: command not found
me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/workers-python/workers/data_simulator/src$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3
Retrieving Poetry metadata

This installer is deprecated. Poetry versions installed using this script will not be able to use 'self update' command to upgrade to 1.2.0a1 or later.
Latest version already installed.
me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/workers-python/workers/data_simulator/src$ poetry run python3 cli.py
poetry: command not found
me@PF2DCSXD:/mnt/c/Users/me/Documents/GitHub/workers-python/workers/data_simulator/src$ 
Run Code Online (Sandbox Code Playgroud)

如果我可以在帖子中添加其他内容以帮助进一步澄清,请告诉我。

python windows python-poetry

64
推荐指数
7
解决办法
16万
查看次数

在平面布局中发现多个顶级包

我正在尝试从使用 Poetry 的源代码安装一个库,但出现此错误

error: Multiple top-level packages discovered in a flat-layout: ['tulips', 'fixtures'].
        
To avoid accidental inclusion of unwanted files or directories,
setuptools will not proceed with this build.
        
If you are trying to create a single distribution with multiple packages
on purpose, you should not rely on automatic discovery.
Instead, consider the following options:
        
1. set up custom discovery (`find` directive with `include` or `exclude`)
2. use a `src-layout`
3. explicitly set `py_modules` or `packages` with a list of …
Run Code Online (Sandbox Code Playgroud)

python python-poetry

64
推荐指数
2
解决办法
4万
查看次数

错误:为 numpy 构建轮子失败,错误:无法为 numpy 构建轮子,这是安装基于 pyproject.toml 的项目所必需的

我在我的项目中使用 python诗歌(https://python-poetry.org/)进行依赖管理。

虽然当我运行时poetry install,它给了我以下错误。

ERROR: Failed building wheel for numpy
  Failed to build numpy
  ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects

Run Code Online (Sandbox Code Playgroud)

我的笔记本电脑上安装了 python 3.9。
我使用安装了 numpy 1.21.5 pip install numpy,我什至尝试将其版本降低到 1.19.5。

虽然我遇到了同样的错误。

我发现很多人ERROR: Failed building wheel for numpy在 python 3.10 中遇到这个错误,他们通过将 python 版本降低到 3.9 来解决它,尽管这对我不起作用。

python macos numpy python-poetry

48
推荐指数
1
解决办法
17万
查看次数

诗歌配置无效 - 不允许附加属性(“组”是意外的)

最近,我在诗歌方面遇到了这个问题。我所有使用诗歌的命令都失败并出现以下错误。

RuntimeError

  The Poetry configuration is invalid:
    - Additional properties are not allowed ('group' was unexpected)
Run Code Online (Sandbox Code Playgroud)

python python-poetry

45
推荐指数
2
解决办法
5万
查看次数

如何使用 Poetry 从现有项目中导入 requirements.txt

我正在现有项目中试用Poetry。它最初使用 pyenv 和 virtual env 所以我有一个requirements.txt包含项目依赖项的文件。

我想requirements.txt使用 Poetry导入文件,以便我可以第一次加载依赖项。我已经查看了诗歌的文档,但我还没有找到一种方法来做到这一点。你可以帮帮我吗?

我知道我可以手动添加所有包,但我希望有一个更自动化的过程,因为有很多包......

python pip python-poetry

38
推荐指数
8
解决办法
1万
查看次数