error importing a f2py compiled module.
![](https://secure.gravatar.com/avatar/f7cec68b1e532a962d5b2feae1bc2374.jpg?s=120&d=mm&r=g)
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 -- Fabrice Silva LMA UPR CNRS 7051 - équipe S2M
![](https://secure.gravatar.com/avatar/2a726b0de1ade0be11fb5bc5a383d71d.jpg?s=120&d=mm&r=g)
On Mon, June 23, 2008 10:38 am, Fabrice Silva wrote:
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
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
![](https://secure.gravatar.com/avatar/f7cec68b1e532a962d5b2feae1bc2374.jpg?s=120&d=mm&r=g)
Le lundi 23 juin 2008 à 14:00 +0300, Pearu Peterson a écrit :
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.
![](https://secure.gravatar.com/avatar/f7cec68b1e532a962d5b2feae1bc2374.jpg?s=120&d=mm&r=g)
Le lundi 23 juin 2008 à 14:10 +0200, Fabrice Silva a écrit :
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... -- Fabrice Silva <silva@lma.cnrs-mrs.fr> LMA UPR CNRS 7051 - équipe S2M
![](https://secure.gravatar.com/avatar/f7cec68b1e532a962d5b2feae1bc2374.jpg?s=120&d=mm&r=g)
Hi all, I am facing this old problem again : Fabrice Silva a écrit :
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 <silva@lma.cnrs-mrs.fr> LMA UPR CNRS 7051 - équipe S2M
![](https://secure.gravatar.com/avatar/f7cec68b1e532a962d5b2feae1bc2374.jpg?s=120&d=mm&r=g)
Le dimanche 30 novembre 2008 à 14:47 +0900, David Cournapeau a écrit :
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). -- Fabrice Silva <silva@lma.cnrs-mrs.fr> LMA UPR CNRS 7051 - équipe S2M
![](https://secure.gravatar.com/avatar/2a726b0de1ade0be11fb5bc5a383d71d.jpg?s=120&d=mm&r=g)
On Mon, June 23, 2008 10:38 am, Fabrice Silva wrote:
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
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
![](https://secure.gravatar.com/avatar/f7cec68b1e532a962d5b2feae1bc2374.jpg?s=120&d=mm&r=g)
Le lundi 23 juin 2008 à 14:00 +0300, Pearu Peterson a écrit :
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.
![](https://secure.gravatar.com/avatar/f7cec68b1e532a962d5b2feae1bc2374.jpg?s=120&d=mm&r=g)
Le lundi 23 juin 2008 à 14:10 +0200, Fabrice Silva a écrit :
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... -- Fabrice Silva <silva@lma.cnrs-mrs.fr> LMA UPR CNRS 7051 - équipe S2M
![](https://secure.gravatar.com/avatar/f7cec68b1e532a962d5b2feae1bc2374.jpg?s=120&d=mm&r=g)
Hi all, I am facing this old problem again : Fabrice Silva a écrit :
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 <silva@lma.cnrs-mrs.fr> LMA UPR CNRS 7051 - équipe S2M
![](https://secure.gravatar.com/avatar/f7cec68b1e532a962d5b2feae1bc2374.jpg?s=120&d=mm&r=g)
Le dimanche 30 novembre 2008 à 14:47 +0900, David Cournapeau a écrit :
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). -- Fabrice Silva <silva@lma.cnrs-mrs.fr> LMA UPR CNRS 7051 - équipe S2M
participants (3)
-
David Cournapeau
-
Fabrice Silva
-
Pearu Peterson