最近写了个小程序,用PyQt5做的界面,写完之后用py2exe打包成独立的exe文件,运行正常。

后来由于需要,调用SciPy.io.loadmat,改写setup.py,打包之后运行错误,提示:

Traceback (most recent call last):
File "comtrade.py", line 7, in <module>
File "C:\Anaconda3\lib\site-packages\scipy\io\__init__.py", line 85, in <module>
from .matlab import loadmat, savemat, whosmat, byteordercodes
File "C:\Anaconda3\lib\site-packages\scipy\io\matlab\__init__.py", line 13, in <module>
from .mio import loadmat, savemat, whosmat
File "C:\Anaconda3\lib\site-packages\scipy\io\matlab\mio.py", line 12, in <module>
from .miobase import get_matfile_version, docfiller
File "C:\Anaconda3\lib\site-packages\scipy\io\matlab\miobase.py", line 22, in <module>
from scipy.misc import doccer
File "C:\Anaconda3\lib\site-packages\scipy\misc\__init__.py", line 47, in <module>
from scipy.special import comb, factorial, factorial2, factorialk
File "C:\Anaconda3\lib\site-packages\scipy\special\__init__.py", line 586, in <module>
from ._ufuncs import *
File "<loader>", line 10, in <module>
File "<loader>", line 8, in __load
ImportError: (No module named 'scipy.special._ufuncs_cxx') 'D:\\work\\comtrade\\dist\\scipy.special._ufuncs.pyd'

可是找了下 \Anaconda3\Lib\site-packages\scipy\special里面,是有_ufuncs_cxx.pyd的,

也就是说py2exe在打包的时候没有把'scipy.special._ufuncs_cxx'打进来,需要在"includes" 里面加进去。

这个加进来之后,运行仍然会提示 (No module named "scipy.integrate")等,缺什么就一并"includes" 进来。

 "includes" : [  'scipy.special._ufuncs_cxx',
"scipy.integrate",
"scipy.integrate.quadpack",
"scipy.sparse.csgraph._validation"],

最终setup.py如下:

 # -*- coding: utf-8 -*-
#py2exe:setup.py from distutils.core import setup
import py2exe
#We need to import the glob module to search for all files.
import glob
import sys
#this allows to run it with a simple double click.
sys.argv.append('py2exe') # We need to exclude matplotlib backends not being used by this executable. You may find
# that you need different excludes to create a working executable withyour chosen backend.
# We also need to include include various numerix libraries that the other functions call.
opts= {
'py2exe':{ "includes" : [ "sip", "matplotlib.backends", "matplotlib.backends.backend_tkagg",
"matplotlib.figure","numpy", "matplotlib.pyplot", "pylab", "six",
"matplotlib.backend_bases", 'scipy.special._ufuncs_cxx',
"scipy.integrate","scipy.integrate.quadpack","scipy.sparse.csgraph._validation"],
"excludes" : ['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg',
'_fltkagg','_gtk', '_gtkcairo'], "dll_excludes":['libgdk-win32-2.0-0.dll','libgobject-2.0-0.dll',"MSVCP90.dll",]
}
} #Save matplotlib-data to mpl-data ( It is located in thematplotlib\mpl-data
#folder and the compiled programs will look for it in \mpl-data
#note: using matplotlib.get_mpldata_info
data_files= [(r'mpl-data',glob.glob(r'C:\Anaconda3\Lib\site-packages\matplotlib\mpl-data\*.*')),
#Because matplotlibrc does not have an extension, glob does not findit (at least I think that's why)
#So add it manually here:
(r'mpl-data',[r'C:\Anaconda3\Lib\site-packages\matplotlib\mpl-data\matplotlibrc']),
(r'mpl-data\images',glob.glob(r'C:\Anaconda3\Lib\site-packages\matplotlib\mpl-data\images\*.*')),
(r'mpl-data\stylelib',glob.glob(r'C:\Anaconda3\Lib\site-packages\matplotlib\mpl-data\stylelib\*.*')),
(r'mpl-data\fonts',glob.glob(r'C:\Anaconda3\Lib\site-packages\matplotlib\mpl-data\fonts\*.*')),
("",[r"C:\Anaconda3\Lib\site-packages\PyQt5\libEGL.dll"]),
("platforms",[r"C:\Anaconda3\Lib\site-packages\PyQt5\plugins\platforms\qwindows.dll"])] #for console program use 'console = [{"script" :"comtrade.py"}]
setup(
#console = [{"script" : 'comtrade.py'}],
name = 'comtrade',
version = '1.0',
windows = [{"script":"comtrade.py", "icon_resources": [(1, "logo.ico")]} ],
options=opts, data_files=data_files)

运行时仍然出错,提示(No module named "linalg"),找来找去也没找到 linalg.pyd这个文件,只好把有 import linalg的地方删掉,运行ok。

py2exe 打包scipy时遇到的问题的更多相关文章

  1. 通过py2exe打包python程序的过程中,解决的一系列问题

    py2exe的使用方法参考<py2exe使用方法>. 注:程序可以在解释器中正常运行,一切问题都出在打包过程中. 问题1: 现象:RuntimeError: maximum recursi ...

  2. python+pygame游戏开发之使用Py2exe打包游戏

    最近在用python+pygame 开发游戏,写完以后在分享给朋友玩的时候遇到了很大的问题,只有搭建了环境才能运行python脚本. 这会吓退99%以上的人……所以把我们的游戏打包(注意是打包而不是编 ...

  3. 使用py2exe打包你的py程序

    软件环境:python3.3.4 + PyQt5 使用py2exe打包写好的py文件,过程如下: 在你要打包的代码文件(比如sample.py)的同文件夹建立一个python代码文件(比如setup. ...

  4. py2exe打包遇到的问题

    py2exe打包python成.exe文件 打包过程和结果 1.创建setup脚本打包文件,其中设置打包的属性和方法.注意:尽量将被打包文件和此打包脚本放在同目录下(因为在尝试非同目录下时,出现了非可 ...

  5. iOS打包导出时出现Missing iOS Distribution signing

    iOS打包导出时出现Missing iOS Distribution signing 上传APP就出现Missing iOS Distribution signing indetity for 打包i ...

  6. [python学习笔记] py2exe 打包

    遇坑 之前经过折腾,pyinstaller打包文件可以在别的windows7上运行.但是,mfk, 客户说是xp系统.崩溃 使用pyinstaller各种折腾,打包出来的依然是不是有效的win32程序 ...

  7. 关于pyinstaller打包程序时设置icon时的一个坑

    关于pyinstaller打包程序时设置icon时的一个坑     之前在用pyinstaller打包程序的时候遇到了关于设置图标的一点小问题,无论在后面加--icon 或是-i都出现报错.查了下st ...

  8. PyQt4 py2exe 打包 HardwareManager

    #!/usr/bin/env python # -*- coding: UTF-8 -*- # 1. 以下代码保存在HardwareManager项目的目录下,名称叫:setup.py: # 2. 打 ...

  9. 用.net installshield打包程序时注册第三方控件

    制作打包程序时如果用到外部控件需要按以下方式操作: 1.将控件及控件所用到的所有DLL加入打包程序. 2.将控件的Register由vsdrfDoNotRegister改为vsdrfCOMSelfRe ...

随机推荐

  1. eclipse查看class文件的源码

    eclipse查看class文件的源码: 1.网上下载jadClipse的jar包和执行文件jad.exe和 net.sf.jadclipse_3.3.0.jar. 2.把上面下载的jar包放在ecp ...

  2. dos 批处理删除svn目录

    转自 http://blog.sina.com.cn/mpl398235717 @echo offecho ********************************************** ...

  3. Palindrome Pairs

    Given a list of unique words. Find all pairs of distinct indices (i, j) in the given list, so that t ...

  4. java keytool证书工具使用小结

    java keytool证书工具使用小结 在Security编程中,有几种典型的密码交换信息文件格式: DER-encoded certificate: .cer, .crt    PEM-encod ...

  5. 三、HTTP抓包测试

    package testHTTP; import java.io.BufferedReader;import java.io.IOException;import java.io.InputStrea ...

  6. 后台dom拼接xml,动态显示统计图

    这个东西让我好生头疼,贴代码吧 // 两秒后模拟点击 setTimeout(function() { // IE if(document.all) { document.getElementById( ...

  7. C语言字符串拷贝

    C语言字符串拷贝利用指针操作,要清楚知道指针的指向 代码如下: #include <stdio.h> #include <assert.h> #include <stri ...

  8. 网站fail_over测试(障害测试)

    确认Web和DB进行操作: 一:确认web: ①确认进程是否存在: ps aux|grep tomcat ②关闭tomcat: /etc/init.d/catalina_sbi stop ③重启tom ...

  9. c++模板使用出错情况error LNK2019: unresolved external symbol "public: float __thiscall Compare<float>::min(void)" (?min@?$Compare@M@@QAEMXZ) referenced in function _main

    将类模板在头文件中定义,类的成员函数在头文件中声明,头文件中只留下接口,函数的实现在另一个.cpp文件中,这样编译出来错误error LNK2019: unresolved external symb ...

  10. JQuery源码解析-- 对象的创建

    使用 $("a") 返回的对象就不再是一个简单的DOM对象了,而是一个复杂的JQuery对象. 那么JQuery是怎么创建对象的. 为了便于分析,我将JQuery中复杂的代码简化了 ...