Script with scipy using py2exe

不羁岁月 提交于 2019-12-09 12:33:44

问题


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.


回答1:


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'])



回答2:


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


来源:https://stackoverflow.com/questions/30754772/script-with-scipy-using-py2exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!