我正在尝试将
pixi
用于 python 库,并且在尝试安装 pipy 依赖项 eif
时遇到错误。
~/code> pixi init test-pixi-eif --format pyproject
✔ Created /home/oliver/code/test-pixi-eif/pyproject.toml
~/code/test-pixi-eif> cd test-pixi-eif/
~/code/test-pixi-eif> pixi add numpy
✔ Added numpy >=2.1.3,<3
~/code/test-pixi-eif> pixi add --pypi eif
× default: error installing/updating PyPI dependencies
├─▶ Failed to prepare distributions
├─▶ Failed to download and build `eif==2.0.2`
╰─▶ Build backend failed to determine requirements with `build_wheel()` (exit status: 1)
[stderr]
Traceback (most recent call last):
File "<string>", line 14, in <module>
requires = get_requires_for_build({})
File "/home/oliver/.cache/rattler/cache/uv-cache/builds-v0/.tmplz6UaX/lib/python3.13/site-packages/setuptools/build_meta.py", line 334, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/oliver/.cache/rattler/cache/uv-cache/builds-v0/.tmplz6UaX/lib/python3.13/site-packages/setuptools/build_meta.py", line 304, in _get_build_requires
self.run_setup()
~~~~~~~~~~~~~~^^
File "/home/oliver/.cache/rattler/cache/uv-cache/builds-v0/.tmplz6UaX/lib/python3.13/site-packages/setuptools/build_meta.py", line 522, in run_setup
super().run_setup(setup_script=setup_script)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/oliver/.cache/rattler/cache/uv-cache/builds-v0/.tmplz6UaX/lib/python3.13/site-packages/setuptools/build_meta.py", line 320, in run_setup
exec(code, locals())
~~~~^^^^^^^^^^^^^^^^
File "<string>", line 3, in <module>
if sys.path[0] == "":
^^^^^^^^^^^^
ModuleNotFoundError: No module named 'numpy'
对应的
pyproject.toml
文件为:
[project]
authors = [{name = "foo", email = "bar"}]
description = "Add a short description here"
name = "test-pixi-eif"
requires-python = ">= 3.11"
version = "0.1.0"
dependencies = ["eif>=2.0.2,<3"]
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling"]
[tool.pixi.project]
channels = ["conda-forge"]
platforms = ["linux-64"]
[tool.pixi.pypi-dependencies]
test_pixi_eif = { path = ".", editable = true }
[tool.pixi.tasks]
[tool.pixi.dependencies]
numpy = ">=2.1.3,<3"
我也尝试过将
eif
放在[tool.pixi.pypi-dependencies]
下,而不是先安装numpy
,但这似乎没有什么区别。
令我困惑的是,当我在 micromamba/conda 环境中手动安装 numpy 时,然后
pip install eif
,我没有遇到任何问题。我认为 pixi 的做法本质上是一样的,但一定有什么地方不同。
看起来缺少 numpy 包。如果是这样,请通过
安装numpypip install numpy
您可以在添加 eif 之前在 Pixi 环境中显式预安装 numpy。您可以先显式添加 numpy:
pixi add numpy
pixi add --pypi eif
我希望这些步骤能够解决问题。既然您喜欢机器学习项目,您也可以看看这个:https://www.pcbway.com/project/shareproject/IoT_AI_driven_Smart_Grocery_Cart_w_Edge_Impulse_5652a9b2.html