Script with scipy using py2exe

3k views Asked by At

I have ran into this during exporting my script (which uses numpy and scipy libraries) via py2exe:

Traceback (most recent call last):
File "imPok.py", line 3, in <module>
File "scipy\misc\__init__.pyc", line 49, in <module>
File "scipy\special\__init__.pyc", line 603, in <module>
File "scipy\special\basic.pyc", line 18, in <module>
File "scipy\special\orthogonal.pyc", line 101, in <module>
File "scipy\linalg\__init__.pyc", line 188, in <module>
File "scipy\linalg\_decomp_update.pyc", line 12, in <module>
File "scipy\linalg\_decomp_update.pyc", line 10, in __load
File "scipy/linalg/_decomp_update.pyx", line 1, in init scipy.linalg._decomp_update (scipy\linalg\_decomp_update.c:35768)
ImportError: No module named cython_blas

Tried:

  • installing cython - no use
  • removing scipy dependencies - that worked, i.e. the trouble is in cooperation between scipy and py2exe.
  • applying the solution of this question - no use

Questions:

  • how can I make that work?
  • what I should/shouldn't do in general to avoid this problems?

Appendix:

These are the problematic lines:

from scipy.misc import imread
import numpy as np

I actually haven't ask for scipy.linalg and scipy.special and yet the py2exe wants them.

2

There are 2 answers

0
Jeff On BEST ANSWER

I ran into this problem today, and found a more thorough solution from here.

opts = {"py2exe": {
    "includes": ['scipy', 'scipy.integrate', 'scipy.special.*','scipy.linalg.*']}}

Then, in your setup.py script, use:

setup(options=opts,windows=['script.py'])
0
jhrf On

scipy.misc must have scipy.linalg.cython_blas as a dependency. To solve this include the following package in your py2exe setup script at the "options > include" level:

scipy.linalg.cython_blas