安装"Sundials"以使用Assimulo
首先,我想说明一下我这么做的原因:我想尝试一些不同的微分方程求解器,以比较它们在我正在进行的项目中的效率和内存使用情况。因此,我想安装Assimulo,因为它有一套求解器,而且使用起来非常友好。
在安装之前,我发现需要先安装“sundials”:
https://computation.llnl.gov/casc/sundials/download/download.html
我下载了它,解压后使用“-fPIC”标志进行安装,因为我使用的是64位的ubuntu。安装“看起来”还不错,没有出现退出状态消息。
然后我按照这些说明安装了assimulo:
http://www.jmodelica.org/assimulo_home/installation.html
我指定了“usr/local/lib”作为sundials的安装路径,因为在运行脚本时,终端显示的就是这个路径。
为了检查它是否正常工作,我下载并安装了nose来进行测试,但它告诉我有些地方出错了。错误信息的一部分是:
======================================================================
ERROR: Failure: ImportError (No module named sundials)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/local/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/local/lib/python2.7/dist-packages/assimulo/tests/test_examples.py", line 21, in <module>
from assimulo.examples import *
File "/usr/local/lib/python2.7/dist-packages/assimulo/examples/cvode_gyro.py", line 22, in <module>
from assimulo.solvers import CVode
File "/usr/local/lib/python2.7/dist-packages/assimulo/solvers/__init__.py", line 23, in <module>
from sundials import IDA, CVode
ImportError: No module named sundials
nose报告的其他五个错误也非常相似。我理解它的意思是模块似乎不在正确的位置,但我该如何解决这个问题呢?
如果有人能帮忙,我将非常感激。这几天我在这方面遇到了很多麻烦。我对linux非常陌生,已经尽力而为,但我安装的东西似乎总是无法正常工作。
操作系统:Ubuntu 12.10 64位。
Python版本:2.7
Numpy/Scipy已经安装。
编辑:这是我安装assimulo的方式,以及终端输出的内容,如果有帮助的话:
nathan@ubuntu:~/Documents/pythoncode/Assimulo-2.1.1$ sudo python setup.py install --sundials-home=/usr/local/lib
running install
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "assimulo.implicit_ode" sources
building extension "assimulo.ode" sources
building extension "assimulo.explicit_ode" sources
building extension "assimulo.problem" sources
building extension "assimulo.solvers.euler" sources
building extension "assimulo.lib.dopri5" sources
f2py options: []
adding 'build/src.linux-x86_64-2.7/fortranobject.c' to sources.
adding 'build/src.linux-x86_64-2.7' to include_dirs.
adding 'build/src.linux-x86_64-2.7/assimulo/thirdparty/hairer/dopri5-f2pywrappers.f' to sources.
building extension "assimulo.lib.rodas" sources
f2py options: []
adding 'build/src.linux-x86_64-2.7/fortranobject.c' to sources.
adding 'build/src.linux-x86_64-2.7' to include_dirs.
adding 'build/src.linux-x86_64-2.7/assimulo/thirdparty/hairer/rodas-f2pywrappers.f' to sources.
building extension "assimulo.lib.radau5" sources
f2py options: []
adding 'build/src.linux-x86_64-2.7/fortranobject.c' to sources.
adding 'build/src.linux-x86_64-2.7' to include_dirs.
adding 'build/src.linux-x86_64-2.7/assimulo/thirdparty/hairer/radau5-f2pywrappers.f' to sources.
build_src: building npy-pkg config files
running build_py
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelFCompiler
Could not locate executable ifort
Could not locate executable ifc
customize LaheyFCompiler
Could not locate executable lf95
customize PGroupFCompiler
Could not locate executable pgfortran
customize AbsoftFCompiler
Could not locate executable f90
customize NAGFCompiler
Found executable /usr/bin/f95
customize VastFCompiler
customize CompaqFCompiler
Could not locate executable fort
customize IntelItaniumFCompiler
Could not locate executable efort
Could not locate executable efc
customize IntelEM64TFCompiler
customize Gnu95FCompiler
Found executable /usr/bin/gfortran
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
running scons
running install_lib
running install_egg_info
Removing /usr/local/lib/python2.7/dist-packages/Assimulo-2.1.1.egg-info
Writing /usr/local/lib/python2.7/dist-packages/Assimulo-2.1.1.egg-info
running install_clib
customize UnixCCompiler
nathan@ubuntu:~/Documents/pythoncode/Assimulo-2.1.1$
1 个回答
在安装assimulo的时候,可以只用 /usr
作为sundials的主目录。我查找过sundials模块里的文件 cvodes.h
,它的位置在 /usr/include/cvodes
。所以,sundials的主目录应该是包含这个include目录的上一级目录,也就是 /usr
。