【问题标题】:Why can I import numpy into my python interpreter but RHEL says numpy not installed?为什么我可以将 numpy 导入我的 python 解释器但 RHEL 说 numpy 未安装?
【发布时间】:2020-10-27 22:45:01
【问题描述】:

如下所示,rpm 告诉我 numpy 没有安装,但我将 numpy 导入我的 python 解释中没有问题。谁能解释为什么会这样? (我不得不将解释器中的 3 个胡萝卜更改为堆栈箭头以显示发生了什么)

x@red-hat-image install]$ rpm -q numpy
package numpy is not installed

x@red-hat-image yum]$ python
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.

->导入 numpy

->

【问题讨论】:

  • rpm 只能显示它已安装的内容。如果您通过 pip 或 conda(或任何其他方式)安装 numpy,rpm 不会知道这一点。
  • 如果你使用pip作为root,you're on the way to breaking your system

标签: python numpy rhel


【解决方案1】:

在Linux系统中安装某些包通常有三种方式:

  1. 使用操作系统标准包管理器:rpmyumapt、...等
  2. 使用./confguremake 命令从源代码构建它
  3. 使用替代的特定包管理器:composerpear 用于 PHP 库,pip 用于 python 库等

有时您可以使用标准操作系统包管理器安装库。但是替代包管理器拥有自己的存储库,其中包含比标准操作系统存储库更多的库。通常在 alter repos 中有更新的版本。 所以使用基于特定语言的包管理器是一种更好的方法。

所以rpm 命令只允许您查看通过标准包管理器安装的包。

在大多数情况下,人们使用pip manager for python。 所以很有可能您的numpy 库是通过pip 安装的。 您可以使用以下方式进行检查:

# for python2 (or python3 depending on your configuration)
pip freeze | grep numpy
# for python3
pip3 freeze | grep numpy

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-12
    • 2019-08-15
    • 2020-02-13
    相关资源
    最近更新 更多