Search code examples
pythonnumpyrhel

Why can I import numpy into my python interpreter but RHEL says numpy not installed?


Per below, rpm tells me numpy isn't installed, yet I have no problem importing numpy into my python interpret. Can anyone explain why that may be? (I had to change the 3 carrots in the interpreter to an arrow for stack to display what happened)

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.

->import numpy

->


Solution

  • Usually there are three ways to install some package in Linux systems:

    1. Using of OS standard package manager: rpm, yum, apt,... etc
    2. Build it from source using ./confgure and make commands
    3. Using alternative specific package managers: composer or pear for PHP libraries, pip for python libraries,... etc

    Sometimes you can install libraries using standard OS package manager. But alternative package managers has own repositories with much more libraries than standard OS repositories. And usually there is newer versions in alter repos. So using specific language based package managers is a better way.

    So rpm command allows you to see only packages installed via standard package manager.

    In most cases people using pip manager for python. So there is high probability that your numpy library was installed via pip. You can check it using:

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