我導入Python庫「接口」位於子文件夾「Fortran_Interface」(包裹着f2py):Python的進口 - Fortran語言是.so裏面。所以從f2py - 導入錯誤(沒有找到圖片)
import Interface
'Interface.so' 被編譯爲鏈接到Fortran的LIB 'libsolver.so'。編譯與命令
gfortran -shared -O2 -o libsolver.so -fPIC Solver/Module_Solver.f90
f2py -c --fcompiler=gfortran -L. -I. -lsolver -m Interface Interface/Module_Interface.f90
我得到的錯誤
ImportError: dlopen(/Users/gmueller/Workspace/PySpinX_G/Fortran_Interface/Interface.so, 2): Library not loaded: libsolver.so
Referenced from: /Users/gmueller/Workspace/PySpinX_G/Fortran_Interface/Interface.so
Reason: image not found
我可以從圖書館的目錄中導入庫,而不是從上面的文件夾進行。在我看來,這是因爲'Interface.so'與相對路徑 h連接到'libsolver.so',python從以上的目錄使用。
我很感激任何想法如何解決這個問題。編譯的.so的絕對路徑沒有工作,以及調用的Python腳本,是從我的主腳本庫目錄...
編輯: 從我的python腳本的文件夾中的符號鏈接lib solver.so,它的工作原理。