我正在尝试使用py2exe在使用库assimulo(微分方程求解器)的软件上构建可执行文件。遇到的问题是在执行期间我收到:
ImportError:没有名为algebraic的模块
确切的错误消息是:
Traceback (most recent call last):
File "main.py", line 89, in <module>
from simulation.simulation import Simulation
File "simulation\simulation.pyc", line 18, in <module>
manages all the action linked to a simulation, like running, saving, replay, etc...
File "solver\assimuloSolver.pyc", line 7, in <module>
Explicit solver to choose in the list of assimulo solvers:
File "assimulo\solvers\__init__.pyc", line 25, in <module>
File "assimulo\solvers\kinsol.pyc", line 12, in <module>
File "assimulo\solvers\kinsol.pyc", line 10, in __load
File "kinsol.pyx", line 1, in init assimulo.solvers.kinsol (assimulo\solvers\kinsol.c:19711)
ImportError: No module named algebraic
在这里,qe可以看到第7行产生了我的烦恼,这一行是
from assimulo.solvers import Radau5DAE
py2exe的setup.py文件如下所示:
from distutils.core import setup
from py2exe.build_exe import py2exe
import sys
from glob import glob
import matplotlib
data_files = [("Microsoft.VC90.CRT", glob(r'C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT\*.*'))]
data_files.extend(matplotlib.get_py2exe_datafiles())
sys.path.append("C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\redist\\x86\\Microsoft.VC90.CRT")
excludes = ['_gtkagg', '_tkagg']
includes = [
"scipy.sparse.csgraph._validation",
"scipy.special._ufuncs_cxx",
]
opts = {
"py2exe": {
"includes":includes,
"excludes":excludes,
}
}
setup(name = "MySoft",
version = "0.1",
data_files=data_files,
windows=[{"script":"main.py"}], options=opts)
如果有人有线索,我会非常感兴趣。 感谢
答案 0 :(得分:0)
有时我发现py2exe无法包含软件包,即使在packages选项中列出,但是发现如果我在setup.py中导入软件包它会开始工作,所以尝试添加{{1}的顶部附近}:
setup.py
有时你会发现
import assimulo
可行,(使用此if False:
import assimulo
会在导入时进行大量设置。)
答案 1 :(得分:0)
我的问题的解决方案是通过在包含选项中添加代数包来获得的:
includes = ["assimulo.algebraic"]
还必须确保将库添加到PATH变量中。如果没有,可以简单地添加sys.path.append(&#34;库的路径&#34;),在我的情况下是
sys.path.append("C:\\Python27\\Lib\\site-packages\\assimulo")
设置文件中的
感谢您的帮助 干杯