Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Fortran的Python模块:LNK1112`模块机器类型';X86和x27;与目标机器类型'冲突;x64和x27`_Python_Python 2.7_Fortran_Gfortran - Fatal编程技术网

使用Fortran的Python模块:LNK1112`模块机器类型';X86和x27;与目标机器类型'冲突;x64和x27`

使用Fortran的Python模块:LNK1112`模块机器类型';X86和x27;与目标机器类型'冲突;x64和x27`,python,python-2.7,fortran,gfortran,Python,Python 2.7,Fortran,Gfortran,所以最近我一直在学习编程、编译和其他东西是如何工作的,但这有点超出了我的深度。目前,我正在尝试安装,以便在Python中使用IGRF(我的大部分工作都是在Python中完成的)。我的第一个问题是,因为这个模型是用Fortran开发的,所以要找到一个合适的编译器。我使用MinGW安装g77和gfortran等 每个编译器都会给我不同的错误。当setup.py默认使用g77时,我在该过程中出现了几次“分配表单无效…”错误,导致“退出状态1失败”。因此,我重命名了g77.exe二进制文件,以便setu

所以最近我一直在学习编程、编译和其他东西是如何工作的,但这有点超出了我的深度。目前,我正在尝试安装,以便在Python中使用IGRF(我的大部分工作都是在Python中完成的)。我的第一个问题是,因为这个模型是用Fortran开发的,所以要找到一个合适的编译器。我使用MinGW安装g77和gfortran等

每个编译器都会给我不同的错误。当setup.py默认使用g77时,我在该过程中出现了几次“分配表单无效…”错误,导致“退出状态1失败”。因此,我重命名了g77.exe二进制文件,以便setup.py被迫使用gfortran.exe(我不确定如何指定要使用的编译器,这都是命令行)

该编译器进一步完成了该过程,但最终以“退出状态为1112时失败”终止。查看输出时,编译器似乎遇到了“致命错误LNK1112:模块计算机类型“X86”与目标计算机类型“x64”冲突”。通过谷歌搜索这个错误,我遇到了几个关于这个问题的论坛。似乎假设我使用的是VisualStudio环境,可以单击一些东西来更改“/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
并检查版本信息。

忘记g77。卸载它以确保它不会干扰进程。它是完全过时的,从错误消息中可以清楚地看出它不适合该代码。代码的一部分是32位编译的,另一部分是64位编译的。你必须把两者都做成一种类型。如果您计划使用大型数据集,最好是64位。看到更多的输出,而不仅仅是您选择的几个位,这将是有益的。注意,标志将是不同的,GFRTRAN不接受Visual C++标志。编辑包含完整的输出。它表示“线程模型:Win32”,所以我猜它是一个32位版本。在哪里可以找到64位版本的gfortran?在与所有其他版本相同的位置不,64位版本还显示“线程模型:win32”。gfortran-v调用32位系统i686和64位系统x86_64。在理想情况下,信息会出现在编译器的_OPTIONS()字符串中,但gfortran却没有。这一行程序打印出任何f2003编译器的位:使用ISO_C_绑定;打印“(*(g0))”,位大小(0_C_INTPTR_T),“位”;恩迪怀疑。我怀疑的唯一原因是路径
d:\mingw\lib\gcc\mingw32\6.3.0
,但我可能错了。OP应该知道他安装了什么类型的编译器,所以我们需要他提供详细信息,而不仅仅是错误消息中的一个字符串,然后是编译器消息中的一个字符串……这是一个不同的问题。请问一个新问题。尤其是当你在这里接受了答案。你会想在新问题中接受不同的答案。另外,请四处搜索一下。您需要链接libgfortran库。我不知道为什么它没有被自动链接到这里。这个网站上也有类似的问题。