Ok, I am making a program using SymPy. I use sympy.Eq, sympy.solve, and sympy.Symbol. When I compile my program and I run the command (It's a User Interface) that uses sympy.solve, sympy.Eq, and sympy.Symbol. It works perfectly when it is not compiled, but when I compile it with py2exe (as a bundled executable), it gives my this error:
Traceback (most recent call last):
File "RateTime.py", line 46, in <module>
File "RateTime.py", line 33, in main
File "RateTime.py", line 4, in get_catch_up_time
File "sympy\solvers\solvers.pyc", line 883, in solve
File "sympy\solvers\solvers.pyc", line 316, in check_assumptions
File "sympy\assumptions\ask.pyc", line 88, in ask
File "sympy\assumptions\assume.pyc", line 94, in _eval_ask
File "sympy\assumptions\assume.pyc", line 157, in eval
File "sympy\utilities\source.pyc", line 26, in get_class
ImportError: No module named handlers
I tried changing the code in source.py from
lookup_view = getattr(__import__(mod_name, {}, {}, ['*']), func_name)
to
exec "import "+mod_name+" as MODULE"
lookup_view = getattr(MODULE, func_name)
And it gave me the error even when the project WASN'T compiled. I assume a python file in sympy is not being included because it is not normally imported immediatly. I had to change it back. Is there a way to fix this? I really need my python project to be distributed as a executable. Thanks!
I think that the ImportError does indeed mean that py2exe didn't pick up sympy.assumptions.handlers nor its submodules. The easiest workaround is probably to add
import sympy.assumptions.handlers.calculus
right where you import sympy.
You may need to do the same for "order", "sets" and "ntheory" in addition to "calculus".
如果您不介意更改sympy代码,我想您可以将这些文件添加到相关的__init__.py
文件中,以便在sympy时将其导入。
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.