我正在导入位于子文件夹‘’(用f2py包装)中的一个Fortran_Interface库'Interface':
import Interface“Interface.so”被编译成到Fortran '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‘与一个相对path链接到'libsolver.so',是python从上面的目录中使用的。
对于如何解决这个问题,我会很感激的。用绝对路径编译..so没有工作,也无法从我的主脚本调用库目录中的python脚本.
编辑:通过从我的python的文件夹到lib solver.so的符号链接,它可以工作。
发布于 2015-01-25 20:48:29
(问题由OP解决并在解决方案中编辑。见Question with no answers, but issue solved in the comments (or extended in chat) )
“任择议定书”写道:
通过从我的python脚本的文件夹到lib solver.so的符号链接,它可以工作。
https://stackoverflow.com/questions/27298818
复制相似问题