我正试图帮助同事获得一个已编译并在我们服务器上运行的Fortran模块。他能够在自己的计算机上本地编译/运行它,但是当我尝试在我们的氙气服务器上复制环境时,该模块将不会加载到脚本中。
环境:
具有Intel(R)Xeon(R)CPU E5-2697 v2的WinServer 2012R2
编译器::tdm64-gcc-5.1.0-2.exe(在安装时检查了fortran支持)
Anaconda版本::4.5.11
Python版本: Python 3.7.1(默认值,2018年10月28日,08:39:03)[MSC v.1912 64位(AMD64)] ::在Win32上的Anaconda,Inc。
编译命令:
python C:\ProgramData\Anaconda3\envs\python_server\Scripts\f2py.py -m nnpx -c --fcompiler=gnu95 --compiler=mingw32 nnpx.f90 --f90flags="-mwindows -m64 -march='ivybridge' -fopenmp -lgomp"
注意::我实际上已经尝试过使用这些f90标志的多种组合,但这些组合似乎都不是魔术组合。
该模块似乎可以编译,并创建一个名为“ nnpx.cp37-win_amd64.pyd”的文件,该文件与以下所示的测试脚本位于同一文件夹中
测试试图加载模块(PYD)的python脚本:
#### BEGIN Script Snippet#########################
import ctypes
import pdb
ctypes.WinDLL("nnpx.cp37-win_amd64.pyd")
#; pdb.set_trace()
#############################
import nnpx as nn
#### END Script Snippet#########################
这是尝试加载该DLL时出现的错误:
(python_server) e:\Python_Server\Fortran>python ..\scripts\nnpx_test.py
Traceback (most recent call last):
File "..\scripts\nnpx_test.py", line 24, in <module>
ctypes.WinDLL("nnpx.cp37-win_amd64.pyd")
File "C:\ProgramData\Anaconda3\envs\python_server\lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 1114] A dynamic link library (DLL) initialization routine failed
以下是Windows系统事件查看器中引发的相关错误:
Fault bucket 1820906866837524874, type 4
Event Name: APPCRASH
Response: Not available
Cab Id: 0
Problem signature:
P1: python.exe
P2: 3.7.1150.1013
P3: 5bd5bc42
P4: libgfortran_64-3.dll
P5: 0.0.0.0
P6: a688a670
P7: c0000005
P8: 0000000000018ae0
P9:
P10:
Attached files:
C:\Users\myuserpin\AppData\Local\Temp\WERBAB7.tmp.appcompat.txt
C:\Users\myuserpin\AppData\Local\Temp\WERC074.tmp.WERInternalMetadata.xml
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_python.exe_b5aa8e775891040bdd452465e375c1e92ab7d9_c1c75637_cab_3e80c082\memory.hdmp
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_python.exe_b5aa8e775891040bdd452465e375c1e92ab7d9_c1c75637_cab_3e80c082\triagedump.dmp
These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_python.exe_b5aa8e775891040bdd452465e375c1e92ab7d9_c1c75637_3cf0dd9f
Analysis symbol:
Rechecking for solution: 0
Report Id: 941538b8-e9d8-11e8-810d-d89d67f4dd04
Report Status: 0
Hashed bucket: 19c0c60458b6bae2d9452925d6eb918a
。
Fault bucket , type 0
Event Name: APPCRASH
Response: Not available
Cab Id: 0
Problem signature:
P1: python.exe
P2: 3.7.1150.1013
P3: 5bd5bc42
P4: libgfortran_64-3.dll
P5: 0.0.0.0
P6: a688a670
P7: c0000005
P8: 0000000000018ae0
P9:
P10:
Attached files:
C:\Users\myuserpin\AppData\Local\Temp\WERBAB7.tmp.appcompat.txt
C:\Users\myuserpin\AppData\Local\Temp\WERC074.tmp.WERInternalMetadata.xml
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_python.exe_b5aa8e775891040bdd452465e375c1e92ab7d9_c1c75637_cab_3e80c082\memory.hdmp
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_python.exe_b5aa8e775891040bdd452465e375c1e92ab7d9_c1c75637_cab_3e80c082\triagedump.dmp
These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_python.exe_b5aa8e775891040bdd452465e375c1e92ab7d9_c1c75637_cab_3e80c082
Analysis symbol:
Rechecking for solution: 0
Report Id: 941538b8-e9d8-11e8-810d-d89d67f4dd04
Report Status: 4
Hashed bucket:
。
Faulting application name: python.exe, version: 3.7.1150.1013, time stamp: 0x5bd5bc42
Faulting module name: libgfortran_64-3.dll, version: 0.0.0.0, time stamp: 0xa688a670
Exception code: 0xc0000005
Fault offset: 0x0000000000018ae0
Faulting process id: 0x4d14
Faulting application start time: 0x01d47de553900866
Faulting application path: C:\ProgramData\Anaconda3\envs\python_server\python.exe
Faulting module path: C:\TDM-GCC-64\bin\libgfortran_64-3.dll
Report Id: 941538b8-e9d8-11e8-810d-d89d67f4dd04
Faulting package full name:
Faulting package-relative application ID:
依赖性检查: 我也尝试过检查依赖项,如建议的here一样,但是似乎无法将它们完全消除(这就是为什么我认为无法让python正确加载模块的原因)。我必须将“ libgcc_s_seh_64-1.dll”和“ libgfortran_64-3.dll”复制到PYD文件所在的文件夹中,然后在依赖项浏览器上将它们显示为“正确”,但是从不显示“ python37.dll”获取正确的校验和。我不知道这是否重要,但是我尝试了在系统上可以找到的每个python37.dll副本(在每个conda环境中),但没有任何效果。它们都给我依赖检查程序中的“校验和不正确”。
关于如何获取此FORTRAN模块以正确加载到python脚本的任何想法或建议?