在虚拟环境中安装libvirt-python失败

9

我目前正在尝试将libvirt-python安装到虚拟环境中。

运行时,我看到了以下输出:

$ pip install libvirt-python
Collecting libvirt-python
  Using cached libvirt-python-3.5.0.tar.gz
Building wheels for collected packages: libvirt-python
  Running setup.py bdist_wheel for libvirt-python ... error
  Complete output from command /home/john/virtenvs/hw/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3_fz8vok/libvirt-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpg1j1nq_wpip-wheel- --python-tag cp35:
  Package libvirt was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libvirt.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libvirt' found
  Package libvirt was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libvirt.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libvirt' found
  running bdist_wheel
  running build
  /usr/bin/pkg-config --print-errors --atleast-version=0.9.11 libvirt
  Package libvirt was not found in the pkg-config search path.
  Perhaps you should add the directory containing `libvirt.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'libvirt' found
  error: command '/usr/bin/pkg-config' failed with exit status 1

  ----------------------------------------
  Failed building wheel for libvirt-python
  Running setup.py clean for libvirt-python
Failed to build libvirt-python
Installing collected packages: libvirt-python
  Running setup.py install for libvirt-python ... error
    Complete output from command /home/john/virtenvs/hw/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3_fz8vok/libvirt-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-leu8ei67-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/john/virtenvs/hw/include/site/python3.5/libvirt-python:
    Package libvirt was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libvirt.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libvirt' found
    Package libvirt was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libvirt.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libvirt' found
    running install
    running build
    /usr/bin/pkg-config --print-errors --atleast-version=0.9.11 libvirt
    Package libvirt was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libvirt.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libvirt' found
    error: command '/usr/bin/pkg-config' failed with exit status 1

    ----------------------------------------
Command "/home/john/virtenvs/hw/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3_fz8vok/libvirt-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-leu8ei67-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/john/virtenvs/hw/include/site/python3.5/libvirt-python" failed with error code 1 in /tmp/pip-build-3_fz8vok/libvirt-python/

没有使用 virtualenv,我可以在 Python shell 中导入 libvirt。

1
你是否按照错误信息的建议进行操作:“也许你应该将包含 libvirt.pc 的目录添加到 PKG_CONFIG_PATH 环境变量中”? - user707650
3个回答

33

pip安装libvirt-python需要系统上存在文件libvirt.pc,因为安装脚本使用pkg-config检查libvirt包的详细信息。

对于Debian,我发现这个文件由`libvirt-dev'包提供。所以你可以尝试执行以下命令:

apt-get install libvirt-dev

或者使用适合你系统的等效命令。


在 Fedora、CentOS/RHEL 上:sudo yum install libvirt-devel - giacom0c
对于CentOS 7,我还需要运行sudo yum install python3-devel - Argyle

0
如果您正在使用基于deb的操作系统,请确保已安装libvirt-dev软件包。

-1

1,对于Ubuntu/Debian操作系统,

apt-get install pkg-config

对于Redhat/Yum操作系统,

yum install -y pkgconfig

对于MacOS,

brew install pkg-config

2,pip install libvirt-python


1
对于MacOS,我还需要安装: brew install libvirt - mava

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接