LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   New user: python numpy import error (https://www.linuxquestions.org/questions/linux-newbie-8/new-user-python-numpy-import-error-908232/)

CosmicThespian 10-14-2011 04:46 PM

New user: python numpy import error
 
New to Linux, new to python...have no idea what I'm doing. Now that that's out of the way....

I have a computer at work with a new installation of Red Hat Enterprise 6.1. I tried starting python - that works (ver 2.5.4). I then tried typing 'import numpy' and received this error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.5/site-packages/numpy/__init__.py", line 130, in <module>
import add_newdocs
File "/usr/local/lib/python2.5/site-packages/numpy/add_newdocs.py", line 9, in <module>
from lib import add_newdoc
File "/usr/local/lib/python2.5/site-packages/numpy/lib/__init__.py", line 13, in <module>
from polynomial import *
File "/usr/local/lib/python2.5/site-packages/numpy/lib/polynomial.py", line 18, in <module>
from numpy.linalg import eigvals, lstsq
File "/usr/local/lib/python2.5/site-packages/numpy/linalg/__init__.py", line 47, in <module>
from linalg import *
File "/usr/local/lib/python2.5/site-packages/numpy/linalg/linalg.py", line 22, in <module>
from numpy.linalg import lapack_lite
ImportError: liblapack.so: cannot open shared object file: No such file or directory

A google search for the last line ("ImportError....") turned up a few things but it was all well over my head. I haven't a clue what this means (except that 'liblapack.so' appears to be missing) or what to do about it.

Help!

knudfl 10-14-2011 05:59 PM

'liblapack.so' is provided by lapack-devel :

# yum provides */liblapack.so

# yum install lapack-devel

CosmicThespian 10-14-2011 06:12 PM

Quote:

Originally Posted by knudfl (Post 4498778)
'liblapack.so' is provided by lapack-devel :

# yum provides */liblapack.so

# yum install lapack-devel

Thanks for the quick response! I tried this....and to make matters more complicated I don't have root access. Getting root access is, unfortunately, not really an option in my work environment. Is there a way to do with this without root?

knudfl 10-14-2011 06:48 PM

Well, you can unpack the rpm's and have e.g. /home/<name>/usr/lib/
( Or /home/<name>/usr/lib64/, if it's a 64bits OS.)

32bits: lapack-3.2.1-4.el6.i686.rpm, lapack-devel-3.2.1-4.el6.i686.rpm
http://ftp.scientificlinux.org/linux...6/os/Packages/

64bits: lapack-3.2.1-4.el6.x86_64.rpm, lapack-devel-3.2.1-4.el6.x86_64.rpm
http://ftp.scientificlinux.org/linux...4/os/Packages/

Use with e.g.
export LD_LIBRARY_PATH=/home/<name>/usr/lib:/usr/lib:/lib && <other-command>

..

CosmicThespian 10-14-2011 07:16 PM

Quote:

Originally Posted by knudfl (Post 4498810)
Well, you can unpack the rpm's and have e.g. /home/<name>/usr/lib/
( Or /home/<name>/usr/lib64/, if it's a 64bits OS.)

32bits: lapack-3.2.1-4.el6.i686.rpm, lapack-devel-3.2.1-4.el6.i686.rpm
http://ftp.scientificlinux.org/linux...6/os/Packages/

64bits: lapack-3.2.1-4.el6.x86_64.rpm, lapack-devel-3.2.1-4.el6.x86_64.rpm
http://ftp.scientificlinux.org/linux...4/os/Packages/

Use with e.g.
export LD_LIBRARY_PATH=/home/<name>/usr/lib:/usr/lib:/lib && <other-command>

..

Ugh....I should emphasize that I'm **very* new to all this. I'm trying to figure out what this means, but a lot of it is unclear.

"unpack the rpm's": I found those files and downloaded them (the 64 bit versions). I'm not sure what 'unpack the rpm's' means. I found an 'rpm' command...is that what I should be using? I don't see a way to get it to install in /home/<name>/usr/lib/.

And then, the export command. I add that to my .bashrc file? What's <other-command> referring to?

I'm sorry if these are very basic questions...I've never tried to do anything like this before and I'm finding the available documentation incredibly obtuse.

knudfl 10-15-2011 08:20 AM

This will unpack to : usr/lib64/*** in the current directory :

1) rpm2cpio lapack-3.2.1-4.el6.x86_64.rpm | cpio -idmv

2) rpm2cpio lapack-devel-3.2.1-4.el6.x86_64.rpm | cpio -idmv

Quote:

And then, the export command
The export command is temporary. Will reset to /usr/lib:/lib etc.
when you exit the terminal.
The LD_LIBRARY_PATH can be added to the bashrc. May work.
Or you can use a "start script", like :
Code:

#!/bin/sh
export LD_LIBRARY_PATH=/home/<name>/usr/lib64:/usr/lib64:/lib64
<other command>


CosmicThespian 10-17-2011 11:40 AM

Thanks again for the reply. That was helpful. That seemed to fix the error I describe above, but now I get this error when trying to import numpy:

>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.5/site-packages/numpy/__init__.py", line 130, in <module>
import add_newdocs
File "/usr/local/lib/python2.5/site-packages/numpy/add_newdocs.py", line 9, in <module>
from lib import add_newdoc
File "/usr/local/lib/python2.5/site-packages/numpy/lib/__init__.py", line 13, in <module>
from polynomial import *
File "/usr/local/lib/python2.5/site-packages/numpy/lib/polynomial.py", line 18, in <module>
from numpy.linalg import eigvals, lstsq
File "/usr/local/lib/python2.5/site-packages/numpy/linalg/__init__.py", line 47, in <module>
from linalg import *
File "/usr/local/lib/python2.5/site-packages/numpy/linalg/linalg.py", line 22, in <module>
from numpy.linalg import lapack_lite
ImportError: libptf77blas.so: cannot open shared object file: No such file or directory

Looks like another missing file. How frustrating!

TobiSGD 10-17-2011 11:47 AM

May be it would be easier to ask the administrator of that machine if he can install the dependencies of numpy for you.

knudfl 10-17-2011 12:12 PM

Quote:

ImportError: libptf77blas.so: cannot open shared object file: No such file
Frustrating ? Use 3 seconds to find the package at http://rpm.pbone.net/
Search >>> Advanced Search , and tick CentOS5 Scientific 5, Redhat EL5.
( Search for "libptf77blas.so".)

Also : These yum commands can be used as unprivileged user :
yum search <package name> ( Or part of package name.)

And : yum provides */libptf77blas.so
→ → atlas-devel

Download atlas-devel, atlas from the EPEL repo
(You'd know that repo name from the rpmpbone search) :
( http://download.fedora.redhat.com/pu...6_64/repoview/ )
http://download.fedora.redhat.com/pub/epel/5/x86_64/
> atlas-devel-3.8.3-1.el5.x86_64.rpm, atlas-3.8.3-1.el5.x86_64.rpm

..

CosmicThespian 10-17-2011 05:20 PM

Well, I downloaded those two files (atlas-devel-3.8.3-1.el5.x86_64.rpm and atlas-3.8.3-1.el5.x86_64.rpm) and used rpm2cpio just as I did with the previous two .rpm files. I'm getting the same error message when I try to import numpy. Does another path need to be set somewhere so python knows where to find libptf77blas.so?

Just curious, is this a known "feature" of Red Hat? I'm surprised that it would ship with an incomplete python installation.

John VV 10-17-2011 06:43 PM

Quote:

Just curious, is this a known "feature" of Red Hat? I'm surprised that it would ship with an incomplete python installation.
it did not

those files will be in the RHN repo
the one that YOU CAN NOT USE without root access, and a paid for support license, to install software and receive updates .

Code:

su -
yum install lapack-devel

and about 30 sec. later it is installed

--- WARNING ----
(atlas-devel-3.8.3-1.el5.x86_64.rpm and atlas-3.8.3-1.el5.x86_64.rpm)
those are for RHEL 5 and NOT for RHL6.1 . those rpms will KILL a rhel6 install

REPLACE THEM with the RHEL 6 rpm's ( el6)

CosmicThespian 10-17-2011 07:53 PM

Quote:

Originally Posted by John VV (Post 4500930)
it did not

those files will be in the RHN repo
the one that YOU CAN NOT USE without root access, and a paid for support license, to install software and receive updates .

Well, I don't have root access.....but it looks like this is all moot anyway. Apparently the files in /usr/local/ are all for Red Hat 5.1 and my machine is the first to have 6.1 installed. Or something to that effect, it's all a bit over my head. It needs to be dealt with on a sys admin level as far as I can tell so I'll just have to wait. Thank you, everyone, for your willingness to help.

knudfl 10-17-2011 09:03 PM

Quote:

I'm getting the same error message when I try to import numpy.
Does another path need to be set somewhere so python knows where
to find libptf77blas.so?
Yes, /home/<name>/usr/lib64/atlas must be added :
Code:

export LD_LIBRARY_PATH=/home/<name>/usr/lib64:/home/<name>/usr/lib64/atlas:/usr/lib64:/lib64 && <other-command>

knudfl 10-17-2011 09:14 PM

Sorry for the EL5 links. ( The EL6 packages may not be different ? )

But anyway, the EL 6 packages are here :
http://ftp.scientificlinux.org/linux...4/os/Packages/
> atlas-devel-3.8.3-12.4.el6.x86_64.rpm, atlas-3.8.3-12.4.el6.x86_64.rpm


All times are GMT -5. The time now is 02:39 AM.