简体   繁体   中英

py2exe and assimulo - No module named algebraic

I am trying to build an executable using py2exe on a soft that uses the library assimulo (differential equation solver). The problem encountered is that during execution I receive:

ImportError: No module named algebraic

The exact error message is:

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

Here qe can see that it is line 7 that produces my troubles, and this line is

from assimulo.solvers import Radau5DAE

the setup.py file for py2exe looks like the following:

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)

If someone has a clue, I would be very interested. Thanks

Sometimes I have found py2exe failing to include packages, even when listed in the packages option, but have found that if I import the package in setup.py it starts to work so try adding, near the top of setup.py :

import assimulo

You will sometimes find that even

if False:
    import assimulo

will work, (use this is assimulo does a lot of setting up on import).

The solution to my problem was obtained by adding, in the includes option, the algebraic package this way:

includes = ["assimulo.algebraic"]

One must also be sure that the library is added to the PATH variable. If not, one can simply add sys.path.append("path to the library"), which in my case was

sys.path.append("C:\\Python27\\Lib\\site-packages\\assimulo")

in the setup file

Thanks for the help Cheers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM