错误:无法为 cysystemd 构建轮子

问题描述 投票:0回答:1

我在安装 systemd 软件包时遇到错误:

pip install systemd

  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      /usr/local/lib/python3.12/site-packages/setuptools/_distutils/dist.py:265: UserWarning: Unknown distribution option: 'build_requires'
        warnings.warn(msg)
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-312
      creating build/lib.linux-x86_64-cpython-312/cysystemd
      copying cysystemd/__init__.py -> build/lib.linux-x86_64-cpython-312/cysystemd
      copying cysystemd/async_reader.py -> build/lib.linux-x86_64-cpython-312/cysystemd
      copying cysystemd/daemon.py -> build/lib.linux-x86_64-cpython-312/cysystemd
      copying cysystemd/journal.py -> build/lib.linux-x86_64-cpython-312/cysystemd
      copying cysystemd/py.typed -> build/lib.linux-x86_64-cpython-312/cysystemd
      running build_ext
      building 'cysystemd._daemon' extension
      creating build/temp.linux-x86_64-cpython-312
      creating build/temp.linux-x86_64-cpython-312/cysystemd
      gcc -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/usr/local/include/python3.12 -c cysystemd/_daemon.c -o build/temp.linux-x86_64-cpython-312/cysystemd/_daemon.o
      cysystemd/_daemon.c:1202:10: fatal error: systemd/sd-daemon.h: No such file or directory
       1202 | #include <systemd/sd-daemon.h>
            |          ^~~~~~~~~~~~~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cysystemd
ERROR: Could not build wheels for cysystemd, which is required to install pyproject.toml-based projects

python pip systemd
1个回答
0
投票

您需要安装
libsystemd-dev
软件包:

sudo apt install libsystemd-dev


systemd
vs
cysystemd
vs
systemd-python

systemd
cysystemd
的别名。正如 pip 页面建议的那样,您应该使用
cysystemd
而不是
systemd
以避免混淆。

systemd-python
是最受欢迎的软件包,但其导入方式与上面不太受欢迎的软件包相同:
import systemd
。很混乱。

这就是为什么如果您没有

requirements.txt
告诉您要安装哪个软件包,那么
systemd-python
很可能就是您正在寻找的。

© www.soinside.com 2019 - 2024. All rights reserved.