所以最近我一直在学习关于编程和编译以及其他东西如何工作的绝对堆栈,但这有点超出了我的深度。目前,我正在尝试安装pyigrf12,以便我可以在 Python 中使用 IGRF(我在其中完成大部分工作)。我的第一个问题是,因为这个模型是用 Fortran 开发的,所以要找到合适的编译器。我使用 MinGW 安装 g77 和 gfortran 等。
每个编译器都会给我不同的错误。当 setup.py 默认使用 g77 时,由于“无效的赋值表单...”错误,我在此过程中出现了几次“失败,退出状态为 1”。所以我重命名了 g77.exe 二进制文件,以便 setup.py 被迫使用 gfortran.exe(我不确定如何指定要使用的编译器,这都是命令行)。
该编译器进一步完成了该过程,但最终以“退出状态为 1112 失败”而终止。查看输出,编译器似乎遇到了“致命错误 LNK1112:模块机器类型‘X86’与目标机器类型‘x64’冲突”。谷歌搜索这个错误,我遇到了几个关于这个问题的论坛。在每种情况下提出的解决方案似乎认为我是使用Visual Studio环境,并且可以点击的东西来改变“/ MACHINE:IX86”标志。
这看起来很简单,但是可以在命令行中完成吗?如果是这样,如何?目前我运行 setup.py 脚本所做的就是
python setup.py develop
在命令提示符中(我在 Windows 机器上)。任何帮助将不胜感激!
编辑:我写的整个输出如下。请注意,我没有对任何内容进行任何更改 - 到目前为止我唯一可以控制的是编译器。其他一切都是 pyigrf 的一部分。虽然看起来这个模块的编译可能存在一些问题,但我想知道是否有任何解决方法。因为它看起来像是某种旗帜......我不确定。老实说,希望出现某种奇迹。这里是:
running develop
running build_scripts
running egg_info
running build_src
build_src
building extension "igrf12" sources
f2py options: ['--quiet']
adding 'build\src.win-amd64-2.7\build\src.win-amd64-2.7\fortranobject.c' to sources.
adding 'build\src.win-amd64-2.7\build\src.win-amd64-2.7' to include_dirs.
build_src: building npy-pkg config files
writing requirements to pyigrf12.egg-info\requires.txt
writing pyigrf12.egg-info\PKG-INFO
writing top-level names to pyigrf12.egg-info\top_level.txt
writing dependency_links to pyigrf12.egg-info\dependency_links.txt
reading manifest file 'pyigrf12.egg-info\SOURCES.txt'
writing manifest file 'pyigrf12.egg-info\SOURCES.txt'
running build_ext
customize MSVCCompiler
customize MSVCCompiler using build_ext
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
customize AbsoftFCompiler
Could not locate executable f90
customize CompaqVisualFCompiler
Could not locate executable DF
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Found executable D:\MinGW\bin\gfortran.exe
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'igrf12' extension
compiling C sources
C:\Users\XXXXX\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ibuild\src.win-amd64-2.7\build\src.win-amd64-2.7 -IC:\ProgramData\Anaconda2\lib\site-packages\numpy\core\include -IC:\ProgramData\Anaconda2\include -IC:\ProgramData\Anaconda2\PC -IC:\ProgramData\Anaconda2\include -IC:\ProgramData\Anaconda2\PC /Tcbuild\src.win-amd64-2.7\igrf12module.c /Fobuild\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\igrf12module.obj
C:\Users\XXXXX\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Ibuild\src.win-amd64-2.7\build\src.win-amd64-2.7 -IC:\ProgramData\Anaconda2\lib\site-packages\numpy\core\include -IC:\ProgramData\Anaconda2\include -IC:\ProgramData\Anaconda2\PC -IC:\ProgramData\Anaconda2\include -IC:\ProgramData\Anaconda2\PC /Tcbuild\src.win-amd64-2.7\build\src.win-amd64-2.7\fortranobject.c /Fobuild\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\build\src.win-amd64-2.7\fortranobject.obj
compiling Fortran sources
Fortran f77 compiler: D:\MinGW\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O0
Fortran f90 compiler: D:\MinGW\bin\gfortran.exe -Wall -g -fno-second-underscore -O0
Fortran fix compiler: D:\MinGW\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O0
compile options: '-Ibuild\src.win-amd64-2.7\build\src.win-amd64-2.7 -IC:\ProgramData\Anaconda2\lib\site-packages\numpy\core\include -IC:\ProgramData\Anaconda2\include -IC:\ProgramData\Anaconda2\PC -IC:\ProgramData\Anaconda2\include -IC:\ProgramData\Anaconda2\PC -c'
gfortran.exe:f77: fortran/igrf12.f
C:\Users\XXXXX\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:d:\mingw\lib\gcc\mingw32\6.3.0 /LIBPATH:d:\mingw\lib /LIBPATH:C:\ProgramData\Anaconda2\libs /LIBPATH:C:\ProgramData\Anaconda2\PCbuild\amd64 /LIBPATH:C:\ProgramData\Anaconda2\PC\VS9.0\amd64 /LIBPATH:C:\ProgramData\Anaconda2\libs /LIBPATH:C:\ProgramData\Anaconda2\PCbuild\amd64 /LIBPATH:C:\ProgramData\Anaconda2\PC\VS9.0\amd64 /EXPORT:initigrf12 build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\igrf12module.obj build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\build\src.win-amd64-2.7\fortranobject.obj build\temp.win-amd64-2.7\Release\fortran\igrf12.o /OUT:igrf12.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\igrf12.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\build\src.win-amd64-2.7\igrf12.pyd.manifest
build\temp.win-amd64-2.7\Release\fortran\igrf12.o : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
从日志看来,您安装了 32 位版本的 gfortran。您需要 64 位版本才能与工具链的其余部分兼容。
确保执行:gfortran -v
并检查版本信息。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句