【问题标题】:Cannot import sos package in python2python2中无法导入sos包
【发布时间】:2021-10-03 05:58:05
【问题描述】:

我正在尝试在rhel8.3中导入python2中的sos包,但出现以下错误

[root@svr_1 site-packages]# python2.7
Python 2.7.17 (default, Aug 18 2020, 09:42:29)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sos
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named sos

软件包的 rpm 已经安装。

[root@svr_1 site-packages]# yum list installed | grep sos
sos.noarch                                        3.9.1-6.el8                                  @InstallMedia
[root@svr_1 site-packages]#

有没有人知道。在 rhel7 中这没问题。

【问题讨论】:

  • 如前所述rpmfind.net/linux/rpm2html/search.php?query=sossos.noarch 是一组工具,而不是 python 模块/包。可以搜索python2-sos吗?
  • 在 rhel7 [root@svr_1 ~]# python2 Python 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2 Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import sos &gt;&gt;&gt;
  • 据我所知,你有多个版本的 python2,当你安装 sos 时,你会得到另一个版本的 python。最好是为你的python2.7安装pip pip.pypa.io/en/stable/installation 然后就可以安装sos python2.7 -m pip install sos

标签: python rhel8


【解决方案1】:

对于任何面临同样问题的人。 rhel8 的默认 python 是 python 3。因此,安装 rhel8 包时,python 包将位于 /usr/lib/python3.6/site-packages 下,并且可以从 python 3 使用。

 [root@svr_1 plugins]# python3
Python 3.6.8 (default, Aug 18 2020, 08:33:21)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sos
>>>

【讨论】:

    猜你喜欢
    • 2019-03-16
    • 2019-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-21
    相关资源
    最近更新 更多