From: Thomas H. <th...@ct...> - 2009-04-24 16:29:17
|
Cédrick FAURY schrieb: > "packages" option doesn't work , neither "includes" or lots or others > options ... > > I wrote the "program" with the single line : > > from scipy import factorial > > and make a package with : > > from distutils.core import setup > import py2exe > setup( windows=[{"script" :"testscipy2exe.py",}]) > > and when I fire up testscipy2exe.exe, the result is : > Traceback (most recent call last): > File "testscipy2exe.py", line 4, in <module> > ImportError: cannot import name factorial > > Of course, I tried to buid it with a lot of options like "packages", > "includes", excludes", "compressed", "optimize", ... > and it's alway the same. I can reproduce the error that you get. Looking into it, I find the following: The factorial function is actually implemented in the scipy.misc.common module; factorial.__module__ is 'scipy.misc.common'. Doing 'from scipy.misc.common import factorial' works fine (also in the exe!), so the scipy.misc.common module is found by py2exe and included in library.zip. Looking into Lib\site-packages\scipy\__init__.py I see that some fancy PackageLoader is probably doing some magic to import a lot of stuff into the 'scipy' namespace. I fear the problem is that the PackageLoader doen't work correctly when the scipy package is in a zip file. I have no time to examine this further; but it looks like there is some code inside scipy\__init__.py that allows to debug the imports. You might also ask on the scipy or numpy list for advice. -- Thanks, Thomas |