我想使用 libvirt 库在 KVM 上安装 VM。在 Mac 上安装 libvirt 库时,我遇到了一个问题。我尝试安装 libvirt 依赖项,但没有用。你能帮我解决这个问题吗?
(venv) Siddharaths-MacBook-Pro-2:Homework1 siddharathgupta$ pip install libvirt-python
Collecting libvirt-python
Using cached https://files.pythonhosted.org/packages/73/37/52c7076b1b44efe4157d0744be7be01df0c0942f44daba458a77a19f9f8d/libvirt-python-4.10.0.tar.gz
Building wheels for collected packages: libvirt-python
Running setup.py bdist_wheel for libvirt-python ... error
Complete output from command /Users/siddharathgupta/PycharmProjects/CSCI561/Homework1/venv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-install-SwC4Jj/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 /private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-wheel-WnOPln --python-tag cp27:
running bdist_wheel
running build
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-install-SwC4Jj/libvirt-python/setup.py", line 366, in <module>
"Programming Language :: Python :: 3",
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Users/siddharathgupta/PycharmProjects/CSCI561/Homework1/venv/lib/python2.7/site-packages/wheel/bdist_wheel.py", line 202, in run
self.run_command('build')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-install-SwC4Jj/libvirt-python/setup.py", line 147, in run
check_minimum_libvirt_version()
File "/private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-install-SwC4Jj/libvirt-python/setup.py", line 40, in check_minimum_libvirt_version
spawn([get_pkgcfg(),
File "/private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-install-SwC4Jj/libvirt-python/setup.py", line 36, in get_pkgcfg
raise Exception("pkg-config binary is required to compile libvirt-python")
Exception: pkg-config binary is required to compile libvirt-python
----------------------------------------
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 /Users/siddharathgupta/PycharmProjects/CSCI561/Homework1/venv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-install-SwC4Jj/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 /private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-record-4drvGZ/install-record.txt --single-version-externally-managed --compile --install-headers /Users/siddharathgupta/PycharmProjects/CSCI561/Homework1/venv/include/site/python2.7/libvirt-python:
running install
running build
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-install-SwC4Jj/libvirt-python/setup.py", line 366, in <module>
"Programming Language :: Python :: 3",
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Users/siddharathgupta/PycharmProjects/CSCI561/Homework1/venv/lib/python2.7/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 573, in run
self.run_command('build')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-install-SwC4Jj/libvirt-python/setup.py", line 147, in run
check_minimum_libvirt_version()
File "/private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-install-SwC4Jj/libvirt-python/setup.py", line 40, in check_minimum_libvirt_version
spawn([get_pkgcfg(),
File "/private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-install-SwC4Jj/libvirt-python/setup.py", line 36, in get_pkgcfg
raise Exception("pkg-config binary is required to compile libvirt-python")
Exception: pkg-config binary is required to compile libvirt-python
----------------------------------------
Command "/Users/siddharathgupta/PycharmProjects/CSCI561/Homework1/venv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-install-SwC4Jj/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 /private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-record-4drvGZ/install-record.txt --single-version-externally-managed --compile --install-headers /Users/siddharathgupta/PycharmProjects/CSCI561/Homework1/venv/include/site/python2.7/libvirt-python" failed with error code 1 in /private/var/folders/qh/gdlxnjkx39g723d68_l5dzhc0000gn/T/pip-install-SwC4Jj/libvirt-python/
You are using pip version 18.0, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
我正在使用 Python 2.7.10
答案1
对于 Ubuntu/Debian 操作系统,
apt-get install pkg-config
对于 Redhat/Yum 操作系统,
yum install -y pkgconfig
对于 MacOS,
brew install pkg-config
安装
libvirt
:pip install libvirt-python
答案2
异常错误信息显示问题
Exception: pkg-config binary is required to compile libvirt-python
该libvirt-python
模块是 libvirt C 库 API 的绑定。为了编译与 相关的 C 代码libvirt-python
,它需要找到 libvirt 库和包含文件。为此,它使用pkg-config
工具,该工具是用于定位库的广泛使用的标准。您似乎没有pkg-config
在主机上安装,因此您需要安装它。您可能可以从中获取适用于 OS-X 的版本homebrew
- libvirt 本身也应该可以从那里获得,如果您还没有获得它的话。