0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

pip install systemdでlegacy-install-failureエラーが出る

Last updated at Posted at 2023-04-05

環境

ubuntu desktop 22
python 3.11.2

やったこと

sudo apt install libsystemd-dev

そして、

pip install systemd

libsystemd-devが無事インストールされてもエラーが発生。

エラー文

$ pip install systemd
Collecting systemd
  Using cached systemd-0.16.1.tar.gz (173 kB)
  Preparing metadata (setup.py) ... done
Installing collected packages: systemd
  DEPRECATION: systemd is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for systemd ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for systemd did not run successfully.
  │ exit code: 1
  ╰─> [23 lines of output]
      /home/tdzz/.pyenv/versions/3.11.2/lib/python3.11/site-packages/setuptools/_distutils/dist.py:264: UserWarning: Unknown distribution option: 'build_requires'
        warnings.warn(msg)
      running install
      /home/tdzz/.pyenv/versions/3.11.2/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-311
      creating build/lib.linux-x86_64-cpython-311/systemd
      copying systemd/journal.py -> build/lib.linux-x86_64-cpython-311/systemd
      copying systemd/daemon.py -> build/lib.linux-x86_64-cpython-311/systemd
      copying systemd/__init__.py -> build/lib.linux-x86_64-cpython-311/systemd
      running build_ext
      building 'systemd._daemon' extension
      creating build/temp.linux-x86_64-cpython-311
      creating build/temp.linux-x86_64-cpython-311/systemd
      gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/tdzz/.pyenv/versions/3.11.2/include/python3.11 -c systemd/_daemon.c -o build/temp.linux-x86_64-cpython-311/systemd/_daemon.o
      systemd/_daemon.c:197:12: fatal error: longintrepr.h: No such file or directory
        197 |   #include "longintrepr.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: legacy-install-failure

× Encountered error while trying to install package.
╰─> systemd

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: pip install --upgrade pip

解決策

pypiにあるsystemdモジュール自体が古いので、明確に言わないがpython3.9以上のバージョンは対応できません。

どうしてもsystemdモジュールを使いたい場合は、python3.8を用意しましょう。

私の場合、pythonを3.8.10に切り替えると、利用可能になりました。

$ pyenv local 3.8.10
$ pip --version
pip 21.1.1 from /home/tdzz/.pyenv/versions/3.8.10/lib/python3.8/site-packages/pip (python 3.8)
$ pip install systemd
Collecting systemd
  Using cached systemd-0.16.1.tar.gz (173 kB)
Using legacy 'setup.py install' for systemd, since package 'wheel' is not installed.
Installing collected packages: systemd
    Running setup.py install for systemd ... done
Successfully installed systemd-0.16.1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?