Page 1 of 1

Trouble with python imports

Posted: Tue Apr 10, 2012 5:43 pm
by aluchko
Using the latest neuron from hg I've hit the following issue

oc>nrnpython("from scipy.linalg import clapack")
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/scipy/linalg/__init__.py", line 9, in <module>
from basic import *
File "/usr/lib64/python2.7/site-packages/scipy/linalg/basic.py", line 14, in <module>
from lapack import get_lapack_funcs
File "/usr/lib64/python2.7/site-packages/scipy/linalg/lapack.py", line 14, in <module>
from scipy.linalg import flapack
ImportError: cannot import name flapack
0

This statement works fine when using python directly

>>> from scipy.linalg import clapack
>>>

And I do have flapack libraries installed.

$ locate flapack
/usr/lib64/python2.7/site-packages/scipy/lib/lapack/flapack.so
/usr/lib64/python2.7/site-packages/scipy/linalg/flapack.so

Any ideas what the cause of the issue might be?

Re: Trouble with python imports

Posted: Wed Apr 11, 2012 5:08 pm
by hines
That is certainly a puzzle since it looked successfully for some items in /usr/lib64/python2.7/site-packages/scipy/linalg.
Is flapack.so the only shared library there? Do other shared libraries that you are able to load also have that name convention?
You might try adding that folder to your PATH or LD_LIBRARY_PATH as an experiment.

Re: Trouble with python imports

Posted: Wed Apr 11, 2012 5:15 pm
by hines
I had no problem with
oc>nrnpython("import scipy.linalg.clapack")
1
MIne is in
/usr/lib/python2.7/dist-packages/scipy/lib/lapack/flapack.so
/usr/lib/python2.7/dist-packages/scipy/linalg/flapack.so

Are you sure the python you launch is the same python used by nrniv? You can check the path in both launch styles.

Re: Trouble with python imports

Posted: Thu Apr 12, 2012 12:31 am
by aluchko
So if I open /usr/lib64/python2.7/site-packages/scipy/linalg/lapack.py, and swap the imports so "from scipy.linalg import clapack" is run first then I get

ImportError: /usr/lib64/python2.7/site-packages/scipy/linalg/clapack.so: undefined symbol: clapack_sgesv

The other .so's in there are "atlas_version.so calc_lwork.so cblas.so clapack.so fblas.so flapack.so _flinalg.so"

If I add an import for any of them I get the "cannot import name" error (except for clapack which has the undefined symbol error), they all work with command line python.

As for the path
oc>nrnpython("import sys;print sys.path")
['', '/home/aluchko/research/optimizers/scypi', '/home/aluchko/lib/python2.7/site-packages', '/home/aluchko/lib64/python2.7/site-packages', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/home/aluchko/.local/lib/python2.7/site-packages', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/Numeric', '/usr/lib64/python2.7/site-packages/PIL', '/usr/lib64/python2.7/site-packages/gst-0.10', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info', '/home/aluchko/nrn-importer/share/nrn/lib/python']
1

The only difference between this path and the path for command line python is the '/home/aluchko/nrn-importer/share/nrn/lib/python' at the end. If I set the two paths to be equal the neuron python still has the same issues.

Re: Trouble with python imports

Posted: Thu Apr 12, 2012 6:56 am
by hines
Since I'm unable to reproduce the problem, I'm afraid I don't have any further suggestions except to verify if you can import anything that involves a .so file in your
/usr/lib64/python2.7/site-packages/... folders.