简体   繁体   中英

Installing numpy on Red Hat 6?

I'm trying to install numpy on a Red Hat (RHEL6) 64-bit linux machine that has Python 2.7. I downloaded and untar'd numpy 1.6.2 from Sourceforge, and I did the following commands in the numpy-1.6.2 folder:

python ./setup.py build
sudo python ./setup.py install #without sudo, this gives a permissions error.

Then, when I do import numpy on the Python prompt, I get ImportError: No module named numpy .

I read somewhere that numpy 1.6.2 is for Python 3.x, so I also tried the above steps with numpy 1.5.1, and I got the same ImportError .

I'm speculating that the solution lies in some environment variable gymnastics, but I'm not sure what files/directories Python needs to "see" that isn't in scope. Any suggestions for how to get numpy working?

I also tried some precompiled binaries for RHEL, but they gave various errors when I did sudo yum install [numpy precompiled binary url].rpm .

As an aside, my motivation for installing numpy is to use PyGnuplot . Also, I've installed numpy and PyGnuplot on other machines before, but it's been on Ubuntu and Mac OS.

RHEL6 ships numpy 1.4.1, see distrowatch . If 1.4.1 is new enough for you, you can install it with:

$ yum install numpy

When I install Python packages on Ubuntu using setup.py packages end up in

/usr/local/lib/python2.7/dist-packages/

assuming Python2.7

If numpy is installed there, you will need to append this path to your Python's path:

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/dist-packages/

you can append it permentanly using ~/.profile

Another way is by adding a .pth to a directory that's already on Python's path, for example

echo "/usr/local/lib/python2.7/dist-packages/" > /usr/local/lib/python2.7/site-packages/dist_pkg.pth

run that last command as root of course

I gave up on using RedHat, and I installed Ubuntu in a VM. It was a one-liner using apt-get .

Not an ideal solution to the question at hand, but I just didn't want to spend any more time chasing down a solution for RedHat.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM