Compile fortran module with f2py and Python 3.6 on Windows 10

前端 未结 3 1565

I\'m trying (and failing) to compile a fortran module (specifically igrf12.f from the BGS) using f2py and Python 3.6 on Windows 10. Python was installed using Anaconda 4.4.1

3条回答
  •  我在风中等你
    2020-12-31 15:26

    I had the same issue, in particular the: ValueError: Symbol table not found of Method 3.

    dsholes' answer was the solution, plus 2 minor points:

    • uninstall all versions of minggw
    • download mingw64 (in my case: x86_64-8.1.0-posix-seh-rt_v6-rev0 ), install it
    • Add mingw64/bin to PATH
    • Then the compilation with f2py -c fortran_file.F90 -m module_name --compiler=mingw32 runs fine, and can be imported properly in Python: import module_name

    However:

    1. your modules should be compiled in the same windows partition as Mingw32 is installed. Else (mingw was under C:\, my project under D:\, I get the following error, due to Relative paths not being read from one partition to another: f2py target file 'C:\\...' not generated

    2. the compiled file may still require some external librairies. In my case, the libquadmath-0.dll in mingw64\bin is needed and should remain in the PATH at all time. Else I get a the following error: ImportError: DLL load failed:. I ended up identifying these dll and copying them within my project.

提交回复
热议问题