python-systemd icon indicating copy to clipboard operation
python-systemd copied to clipboard

Can not install in python virtual environment?

Open Jibun-no-Kage opened this issue 1 year ago • 3 comments

My activated python virtual environment is functional and other installations of modules in the environment work without error, but not your module....

(Tally-Echo) root@OBS:~/Tally-Echo# pip3 install systemd-python
Collecting systemd-python
  Using cached systemd-python-235.tar.gz (61 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [27 lines of output]
      Traceback (most recent call last):
        File "/root/Tally-Echo/Tally-Echo/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/root/Tally-Echo/Tally-Echo/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/root/Tally-Echo/Tally-Echo/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-78d3j1hy/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-78d3j1hy/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-78d3j1hy/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 516, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-78d3j1hy/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 318, in run_setup
          exec(code, locals())
        File "<string>", line 55, in <module>
        File "<string>", line 40, in lib
        File "<string>", line 18, in pkgconfig
        File "<string>", line 6, in call
        File "/usr/lib/python3.12/subprocess.py", line 1026, in __init__
          self._execute_child(args, executable, preexec_fn, close_fds,
        File "/usr/lib/python3.12/subprocess.py", line 1955, in _execute_child
          raise child_exception_type(errno_num, err_msg, err_filename)
      FileNotFoundError: [Errno 2] No such file or directory: 'pkg-config'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

I can install module globally via...

# apt install python3-systemd

However, that is not applicable to the virtual environment model, thus does not solve the core issue.

Environment is Ubuntu 24.0...

# cat /etc/os-release
PRETTY_NAME="Ubuntu 24.10"
NAME="Ubuntu"
VERSION_ID="24.10"
VERSION="24.10 (Oracular Oriole)"
VERSION_CODENAME=oracular
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=oracular
LOGO=ubuntu-logo

Jibun-no-Kage avatar Oct 25 '24 01:10 Jibun-no-Kage

it tries to build the C module from source, but can't because pkg-config is missing, see

  FileNotFoundError: [Errno 2] No such file or directory: 'pkg-config'

behrmann avatar Oct 25 '24 12:10 behrmann

Yeah... back tracking to resolve now. Debian 12 avoided the issue using global module install, and let the virtualenv use the global instance. But on Ubuntu was trying to get module to be only local to virutalenv. And tripped over the issue. I have not used Ubuntu 24.x yet, so ran into a few quirks I have not experienced with Debian 12. I will post steps... if I figure it out. :)

Jibun-no-Kage avatar Oct 25 '24 14:10 Jibun-no-Kage

Just:

$ sudo apt install pkg-config

hongquan avatar Jun 06 '25 18:06 hongquan