error importing a f2py compiled module.

Dear all I've tried to run f2py on a fortran file which used to be usable from python some months ago. Following command lines are applied with success (no errors raised) : f2py -m modulename -h tmpo.pyf --overwrite-signature tmpo.f f2py -m modulename -c --f90exec=/usr/bin/f95 tmpo.f
The output of these commands is available here: http://paste.debian.net/7307
When importing in Python with "import modulename", I have an ImportError: Traceback (most recent call last): File "Solveur.py", line 44, in <module> import modulename as Modele ImportError: modulename.so: failed to map segment from shared object: Operation not permitted
How can that be fixed ? Any suggestion ? Thanks

On Mon, June 23, 2008 10:38 am, Fabrice Silva wrote:
Dear all I've tried to run f2py on a fortran file which used to be usable from python some months ago. Following command lines are applied with success (no errors raised) : f2py -m modulename -h tmpo.pyf --overwrite-signature tmpo.f f2py -m modulename -c --f90exec=/usr/bin/f95 tmpo.f
First, it is not clear what compiler is f95. If it is gfortran, then use the command f2py -m modulename -c --fcompiler=gnu95 tmpo.f
If it is something else, check the output of
f2py -c --help-fcompiler
and use appropiate --fcompiler switch.
Second, I hope you realize that the first command has no effect to the second command. If you have edited the tmpo.pyf file, then use the following second command:
f2py tmpo.pyf -c --fcompiler=gnu95 tmpo.f
The output of these commands is available here: http://paste.debian.net/7307
When importing in Python with "import modulename", I have an ImportError: Traceback (most recent call last): File "Solveur.py", line 44, in <module> import modulename as Modele ImportError: modulename.so: failed to map segment from shared object: Operation not permitted
How can that be fixed ? Any suggestion ?
I don't have ideas what is causing this import error. Try the instructions above, may be it is due to some compile object conflicts.
HTH, Pearu

Le lundi 23 juin 2008 à 14:00 +0300, Pearu Peterson a écrit :
First, it is not clear what compiler is f95. If it is gfortran, then use the command f2py -m modulename -c --fcompiler=gnu95 tmpo.f
If it is something else, check the output of
f2py -c --help-fcompiler
and use appropiate --fcompiler switch.
Second, I hope you realize that the first command has no effect to the second command. If you have edited the tmpo.pyf file, then use the following second command:
f2py tmpo.pyf -c --fcompiler=gnu95 tmpo.f
Thanks for these comments. The compiler was, following all the symbolic links, gfortran so that I corrected the switch to gnu95. The first line was the residue of some tests I've done in the past. With the command line f2py -c --quiet -m modulename --fcompiler=gnu95 fortranfile.f it compiles as before, but I still can not import the module in python.
I don't have ideas what is causing this import error. Try the instructions above, may be it is due to some compile object conflicts.
The only posts on mailing lists I've read mention security policies (SElinux) and /tmp execution limitations...

Le lundi 23 juin 2008 à 14:10 +0200, Fabrice Silva a écrit :
I don't have ideas what is causing this import error. Try the instructions above, may be it is due to some compile object conflicts.
The only posts on mailing lists I've read mention security policies (SElinux) and /tmp execution limitations...
Another point is that the working directory has been created by a subversion checkout command but has proper permissions drwxr-xr-x 4 fab fab 4096 jui 14 13:29 lib as the fortran and the shared object files : -rwxr-xr-x 1 fab fab 6753 jui 9 14:14 systeme.f -rwxr-xr-x 1 fab fab 85746 jui 14 13:21 systeme.so
Moving these files in another directory (and adding this latter to path) suppress the import problem...

Hi all, I am facing this old problem again :
Fabrice Silva a écrit :
Dear all I've tried to run f2py on a fortran file which used to be usable from python some months ago. Following command line are applied with success (no errors raised) : f2py -m modulename -c --f90exec=gnu95 tmpo.f
When importing in Python with "import modulename", I have an ImportError: Traceback (most recent call last): File "Solveur.py", line 44, in <module> import modulename as Modele ImportError: modulename.so: failed to map segment from shared object: Operation not permitted
A way of solving this issue was to move the shared object file to another directory. But I want to figure out what is happening exactly. Googling a lot indicates that selinux would be the cause of this issue... Has anyone a suggestion?

Fabrice Silva wrote:
A way of solving this issue was to move the shared object file to another directory. But I want to figure out what is happening exactly. Googling a lot indicates that selinux would be the cause of this issue... Has anyone a suggestion?
Disabling selinux ?
David

Le dimanche 30 novembre 2008 à 14:47 +0900, David Cournapeau a écrit :
Fabrice Silva wrote:
A way of solving this issue was to move the shared object file to another directory. But I want to figure out what is happening exactly. Googling a lot indicates that selinux would be the cause of this issue... Has anyone a suggestion?
Disabling selinux ?
It might be an acceptable answer, but I found another : using f2py-compiled modules seems not to work on ext3 file-systems without the exec option. I only needed to add the 'exec' option in /etc/fstab (debian).
participants (3)
-
David Cournapeau
-
Fabrice Silva
-
Pearu Peterson