使用 Conda + Poetry 进行机器学习项目有意义吗?让我分享一下我(新手)的理解,请指正或赐教:
据我了解,Conda和Poetry有不同的目的,但很大程度上是多余的:
我的想法是同时使用两者并划分它们的角色:让 Conda 担任环境管理器,让 Poetry 担任包管理器。我的推理是(听起来)Conda 最适合管理环境,可用于编译和安装非 python 包,尤其是 CUDA 驱动程序(用于 GPU 功能),而 Poetry 作为 Python 包管理器比 Conda 更强大。
通过在 Conda 环境中使用 Poetry,我成功地相当轻松地完成了这项工作。诀窍是不要使用 Poetry 来管理 Python 环境:我没有使用poetry shell
or 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 …
我刚刚更新到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) 当一个项目仅通过via pyproject.toml
(即没有文件)指定时setup.{py,cfg}
,如何以可编辑模式通过via pip
(即python -m pip install -e .
)安装它?
我尝试了setuptools
和poetry
构建系统,但都不起作用:
[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) 我是第一次使用 Poetry。\n我有一个非常简单的项目。基本上
\na_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 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
毫无问题地运行,但是该错误消息是什么意思?
我有一个不包含requirements.txt
. 但它有一个pyproject.toml
文件。
如何下载此 Python 项目所需的包(依赖项)并使用pyproject.toml
Pip 包管理器(而不是构建工具 Poetry)声明。
因此pip download -r requirements.txt
,而不是类似的东西pip download -r pyproject.toml
。
最近我在诗歌方面遇到了一百万零一个问题。
我昨天已经完全安装并工作了,但是重新启动我的机器后,我又遇到了问题;(
即使在重新启动后,是否有办法在我的终端中始终识别诗歌?
系统规格:
终端:
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)
如果我可以在帖子中添加其他内容以帮助进一步澄清,请告诉我。
我正在尝试从使用 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诗歌(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 来解决它,尽管这对我不起作用。
最近,我在诗歌方面遇到了这个问题。我所有使用诗歌的命令都失败并出现以下错误。
RuntimeError
The Poetry configuration is invalid:
- Additional properties are not allowed ('group' was unexpected)
Run Code Online (Sandbox Code Playgroud) 我正在现有项目中试用Poetry。它最初使用 pyenv 和 virtual env 所以我有一个requirements.txt
包含项目依赖项的文件。
我想requirements.txt
使用 Poetry导入文件,以便我可以第一次加载依赖项。我已经查看了诗歌的文档,但我还没有找到一种方法来做到这一点。你可以帮帮我吗?
我知道我可以手动添加所有包,但我希望有一个更自动化的过程,因为有很多包......