Reputation: 99
I am trying to import a fortran subroutine into python code. Following this guide https://notmatthancock.github.io/2017/02/10/calling-fortran-from-python.html I have added the following line into my fortran code:
!f2py intent(in) :: ear,ne,parames,ifl
!f2py intent(out) photar,photer
However when I try to use f2py -c fireball_ES_param.f -m fireball
to create fireball.so to import in my python code I get several hundreds of warnings, which might be the problem but I am not sure: https://www.4shared.com/s/f2ynHZ_Wjda (it's too long to be posted here).
In any case, the fireball.cpython-34m.so
file gets created, but when I try to import that from python I get:
$ python
Python 2.7.6 (default, Nov 13 2018, 12:45:42) [GCC 4.8.4] on
linux2 Type "help", "copyright", "credits" or "license" for more
information.
>>> import fireball Traceback (most recent call last):
File "<stdin>", line 1, in <module> ImportError:
No module named fireball
I tried:
import sys
sys.path.append('/path/to/folder/containing/fireball.cpython-34m.so')
but got the same result. I am not sure if there is a problem with the creation of fireball.so
, or with its import
.
Upvotes: 1
Views: 312
Reputation: 7293
f2py links to Python 3.4 (hence the 34 in fireball.cpython-34m.so
) but python3 is actually version 3.6 (see you last comment).
Your options:
pip install --user -U numpy
should do. Then rebuild the extension.Upvotes: 1