【问题标题】:Installing rpm and yum in anaconda python on centos 7在centos 7上的anaconda python中安装rpm和yum
【发布时间】:2017-05-03 19:25:01
【问题描述】:

如何在 CentOS 的 anaconda 环境中安装 redhat yum 软件包?这些包存在于标准的 Centos dist 中:

$ lsb_release -d
Description:    CentOS Linux release 7.3.1611 (Core)
$ python
Python 2.7.5 (default, Nov  6 2016, 00:28:07)
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpm
>>> import yum 
>>> print(rpm.__package__, rpm.__file__, rpm.__path__,rpm.__version__)
('rpm', '/usr/lib64/python2.7/site-packages/rpm/__init__.pyc', ['/usr/lib64/python2.7/site-packages/rpm'], '4.11.3')
>>> print(yum.__package__, yum.__file__, yum.__path__,yum.__version__)
('yum', '/usr/lib/python2.7/site-packages/yum/__init__.pyc', ['/usr/lib/python2.7/site-packages/yum'], '3.4.3')

我找不到适用于 anaconda 的类似软件包(以我所知道的方式):

$ source anaconda3/bin/activate python2.7  
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org 
>>> import rpm;
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named rpm
>>> import yum  
Traceback (most recent call last):  
File "<stdin>", line 1, in <module>
ImportError: No module named yum
>>> 

pip 和 conda search 似乎也没有这些包。

【问题讨论】:

    标签: python anaconda centos7


    【解决方案1】:

    当你运行源码时 anaconda3/bin/激活python2.7 您正在使用不同的虚拟环境运行 python2.7,其中包存储库不同。您应该获取 venv 并在那里安装软件包。

    【讨论】:

    • 谢谢,我明白了。但我不明白除了 .rpm 文件在哪里可以找到包。而且我不明白如何将它安装到 anaconda 环境中。
    • 这取决于 virtualenv 是如何创建的。某些选项允许您复制系统包,但如果在 venv 创建后安装了 rpm,则以后不会同步。
    猜你喜欢
    • 1970-01-01
    • 2020-10-24
    • 2020-04-27
    • 2021-05-10
    • 2013-07-30
    • 2018-09-13
    • 2016-10-11
    • 2011-01-08
    • 1970-01-01
    相关资源
    最近更新 更多