f2py compiled module not found by python
Hello, I'm trying to build a package on Linux (Ubuntu) that contains a fortran module, built using f2py. However, despite the module building and installing without error, python cannot seem to see it (see log below). This works fine on Windows and Mac; the problem only seems to happen on Linux: In [1]: import PyMC ----------------------------------------------- exceptions.ImportError Traceback (most recent call last) /home/tianhuil/≤ipython console> /usr/lib/python2.4/site-packages/PyMC/__init__.py /home/tianhuil/≤string> /usr/lib/python2.4/site-packages/PyMC/MCMC.py ImportError: No module named flib /usr/lib/python2.4/site-packages/PyMC/MCMC.py Notice that the module exists in the site-packages directory: tianhuil <at> tianhuil:/usr/lib/python2.4/site-packages/PyMC$ ll total 432 drwxr-xr-x 2 root root 4096 2008-02-03 17:24 Backends -rwxrwx--- 1 root root 195890 2008-02-03 17:24 flib.so -rwxrwx--- 1 root root 259 2008-02-03 17:14 __init__.py -rw-r--r-- 1 root root 473 2008-02-03 17:24 __init__.pyc -rwxrwx--- 1 root root 10250 2008-02-03 17:14 Matplot.py -rw-r--r-- 1 root root 7516 2008-02-03 17:24 Matplot.pyc -rwxrwx--- 1 root root 98274 2008-02-03 17:14 MCMC.py -rw-r--r-- 1 root root 79039 2008-02-03 17:24 MCMC.pyc drwxr-xr-x 2 root root 4096 2008-02-03 17:24 Tests -rwxrwx--- 1 root root 6631 2008-02-03 17:14 TimeSeries.py -rw-r--r-- 1 root root 5043 2008-02-03 17:24 TimeSeries.pyc
On Wed, February 6, 2008 8:35 pm, Chris wrote:
Hello,
I'm trying to build a package on Linux (Ubuntu) that contains a fortran module, built using f2py. However, despite the module building and installing without error, python cannot seem to see it (see log below). This works fine on Windows and Mac; the problem only seems to happen on Linux:
Can you import flib module directly? That is, what happens if you execute cd .../PyMC PYTHONPATH=. python -c 'import flib' ? Pearu
Pearu Peterson <pearu <at> cens.ioc.ee> writes:
This works fine on Windows and Mac; the problem only seems to happen on Linux:
Can you import flib module directly? That is, what happens if you execute cd .../PyMC PYTHONPATH=. python -c 'import flib'
It gives a "no module named flib" error.
Unless you try to run it as root, it will not work. Your file permissions are a mess. Please do the following (as root or via sudo) and try again $ chmod 755 <path/to>/flib.so On 2/6/08, Chris <listservs@mac.com> wrote:
Pearu Peterson <pearu <at> cens.ioc.ee> writes:
This works fine on Windows and Mac; the problem only seems to happen on Linux:
Can you import flib module directly? That is, what happens if you execute cd .../PyMC PYTHONPATH=. python -c 'import flib'
It gives a "no module named flib" error.
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
-- Lisandro Dalcín --------------- Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) PTLC - Güemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594
Dear list, I'm using old numarray C api with numpy. It seems that there is a bug when using the PyArray_FromDims function. for example, if I define : acc = (PyArrayObject *) PyArray_FromDims(pos->nd,pos->dimensions,pos->descr->type_num); where pos is PyArrayObject *pos; (3x3 array) when using return PyArray_Return(acc); I get array([], shape=(3, 0), dtype=float32) It is possible to make everything works if I use the following lines instead : int ld[2]; ld[0]=pos->dimensions[0]; ld[1]=pos->dimensions[1]; acc = (PyArrayObject *) PyArray_FromDims(pos->nd,ld,pos->descr->type_num); So, the problem comes from the pos->dimensions. Is it a known bug ? (I'm working on a linux 64bits machine.) Cheers, yves
Hi, What type is pos->dimensions in your case ? It may be long (64bits long) instead of the expected int (32bits) or something like that ? Matthieu 2008/2/8, Yves Revaz <yves.revaz@obspm.fr>:
Dear list,
I'm using old numarray C api with numpy. It seems that there is a bug when using the PyArray_FromDims function.
for example, if I define : acc = (PyArrayObject *) PyArray_FromDims(pos->nd,pos->dimensions,pos->descr->type_num);
where pos is PyArrayObject *pos; (3x3 array)
when using return PyArray_Return(acc); I get array([], shape=(3, 0), dtype=float32)
It is possible to make everything works if I use the following lines instead : int ld[2]; ld[0]=pos->dimensions[0]; ld[1]=pos->dimensions[1]; acc = (PyArrayObject *) PyArray_FromDims(pos->nd,ld,pos->descr->type_num);
So, the problem comes from the pos->dimensions.
Is it a known bug ?
(I'm working on a linux 64bits machine.)
Cheers,
yves
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
-- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher
Matthieu Brucher wrote:
Hi,
What type is pos->dimensions in your case ? It may be long (64bits long) instead of the expected int (32bits) or something like that ?
yes, pos->dimensions is a 64bits long while PyArray_FromDims expects 32bits int. Why is it so ?
Matthieu
2008/2/8, Yves Revaz <yves.revaz@obspm.fr <mailto:yves.revaz@obspm.fr>>:
Dear list,
I'm using old numarray C api with numpy. It seems that there is a bug when using the PyArray_FromDims function.
for example, if I define : acc = (PyArrayObject *) PyArray_FromDims(pos->nd,pos->dimensions,pos->descr->type_num);
where pos is PyArrayObject *pos; (3x3 array)
when using return PyArray_Return(acc); I get array([], shape=(3, 0), dtype=float32)
It is possible to make everything works if I use the following lines instead : int ld[2]; ld[0]=pos->dimensions[0]; ld[1]=pos->dimensions[1]; acc = (PyArrayObject *) PyArray_FromDims(pos->nd,ld,pos->descr->type_num);
So, the problem comes from the pos->dimensions.
Is it a known bug ?
(I'm working on a linux 64bits machine.)
Cheers,
yves
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org <mailto:Numpy-discussion@scipy.org> http://projects.scipy.org/mailman/listinfo/numpy-discussion
-- French PhD student Website : http://matthieu-brucher.developpez.com/ Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn : http://www.linkedin.com/in/matthieubrucher ------------------------------------------------------------------------
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Revaz Yves wrote:
Matthieu Brucher wrote:
Hi,
What type is pos->dimensions in your case ? It may be long (64bits long) instead of the expected int (32bits) or something like that ?
yes, pos->dimensions is a 64bits long while PyArray_FromDims expects 32bits int.
Why is it so ?
PyArray_FromDims is backward compatible Numeric API which did not support 64-bit correctly. PyArray_SimpleNew is the equivalent that accepts 64-bit dimensions information and is what you should be using. -Travis O.
PyArray_FromDims is backward compatible Numeric API which did not support 64-bit correctly.
PyArray_SimpleNew is the equivalent that accepts 64-bit dimensions information and is what you should be using.
ok, excellent ! thanks for the answer. yves
-Travis O.
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
participants (7)
-
Chris
-
Lisandro Dalcin
-
Matthieu Brucher
-
Pearu Peterson
-
Revaz Yves
-
Travis E. Oliphant
-
Yves Revaz