python-2.7 - 警告 warn(warning_msg) rpm
问题描述
OS - Ubuntu-16.04 LTS
Python Version - 2.7.12
20.2.4 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
问题:
python2 -c 'import rpm'
/usr/local/lib/python2.7/dist-packages/rpm.py:15: UserWarning: The RPM Python bindings are not currently available via PyPI.
Please install them with your distro package manager (typically called
'python2-rpm' or 'python3-rpm'), and ensure that any virtual environments
needing the API are configured to be able to see the system site packages
directory.
warnings.warn(warning_msg)
由于上述错误,我的 python 脚本执行失败。请指导我修复此错误。
解决方案
这个错误对我来说似乎很清楚。您需要使用您的发行版包管理器来安装 rpm。由于您使用的是 ubuntu 和 python 2,它应该是
sudo apt-get install python-rpm