Install f2py with python3

我的未来我决定 提交于 2019-12-09 17:16:40

问题


I need to call routines from Fortran modules within Python. I did it with f2py and python2.7. It worked pretty well.

Now, I have to use it with python3 but f2py does not seem to be compatible with python3.

I see that some people use a version called f2py3, but it is neither available through pip, not through macports (I am using a Mac). Also, python3+numpy+f2py seem to be already integrated in Fedora.

Does anyone have managed to use f2py3 (or its equivalent) with python3 on a Mac? If not, what alternate solution do you propose to link Fortran libraries with python3?


回答1:


As an alternative, you can use ctypes and fortran-iso-c-binding to call Fortran routines without relying on f2py. The downside of this approach is that you need to specify the interfaces yourself.

Here is an example I posted on SO some time ago.



来源:https://stackoverflow.com/questions/30000857/install-f2py-with-python3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!