Anaconda Python、Pyinstaller 3.1.1、脚本到 exe、运行 时间错误
Anaconda Python, Pyinstaller 3.1.1, script to exe, run time error
遇到错误消息"pyi_rth_pkgres.py returns -1"
当运行 python脚本(Python版本3.5.1)在Anaconda 64环境中执行时,截至2016年4月由Pyinstaller 3.1.1编译(编译过程没有任何错误)。
脚本使用:
pandas 0.18
qt 4.8.7
qtpy 1.0
import pandas as pd
import numpy as np
from PyQt4 import QtCore, QtGui
import sys
import re
class mainWgt(QtGui.QMainWindow):
def __init__(self):
# regex stuff
rex = re.compile('(?<=ss)\d+')
match = rex.search('ss23423').group(0)
# Pandas stuff
self.df = pd.DataFrame(data=np.random.randn(100, 10))
self.df[4] = self.df[1] + self.df[2]
self.df[5] = self.df.apply(lambda x: '{}_{}'.format(x[1], x[2]), axis=1)
# PyQt stuff
super().__init__()
self.resize(1000, 1000)
self.rootWgt = QtGui.QWidget(self)
self.table = QtGui.QTableWidget(self.rootWgt)
self.rootWgt_lay = QtGui.QGridLayout(self.rootWgt)
self.rootWgt_lay.addWidget(self.table, 0, 0, 1, 1)
self.setCentralWidget(self.rootWgt)
self.table.setColumnCount(11)
self.table.setRowCount(111)
# all together
self.table.setItem(0, 0, QtGui.QTableWidgetItem())
self.table.item(0,0).setText(match)
for i in self.df:
for j, item in enumerate(self.df[i]):
self.table.setItem(j, i, QtGui.QTableWidgetItem())
self.table.item(j, i).setText(str(item))
#} ^ class mainWgt(QtGui.QMainWindow):
app = QtGui.QApplication(sys.argv)
gui = mainWgt()
gui.show()
sys.exit(app.exec_())
这是一个涉及 qtpy 和 pandas 的简短示例代码。
我可以使用从 anaconda64 默认下载的 windows 和 pycharm 社区版编译此代码,全部下载于 2016-04-07:
[0] 为 windows 安装 Anaconda64,而无需事先安装 python。在撰写本文时,Anaconda 默认会同时安装 3.4.3 和 3.5.1 环境。但这不会让我在接下来的步骤中感到悲伤。
[1] cmd: pip install pyinstaller, pip install 可以检测到Anaconda的python.
[2] 将软件包 "setuptools" 还原为 19.2。我在 pycharm(设置、项目:、项目解释器)中做到了这一点
[3] 按照如何使用 pyinstaller 的说明进行操作,这里的所有内容都应该 google-able
警告:结果是一个 200MB 3000+ 文件夹。如果你只是想要一个快速的 exe 来做一些小杂务,请远离大包。 Pandas 其脚本形式处于最佳状态。
遇到错误消息"pyi_rth_pkgres.py returns -1"
当运行 python脚本(Python版本3.5.1)在Anaconda 64环境中执行时,截至2016年4月由Pyinstaller 3.1.1编译(编译过程没有任何错误)。
脚本使用:
pandas 0.18
qt 4.8.7
qtpy 1.0
import pandas as pd
import numpy as np
from PyQt4 import QtCore, QtGui
import sys
import re
class mainWgt(QtGui.QMainWindow):
def __init__(self):
# regex stuff
rex = re.compile('(?<=ss)\d+')
match = rex.search('ss23423').group(0)
# Pandas stuff
self.df = pd.DataFrame(data=np.random.randn(100, 10))
self.df[4] = self.df[1] + self.df[2]
self.df[5] = self.df.apply(lambda x: '{}_{}'.format(x[1], x[2]), axis=1)
# PyQt stuff
super().__init__()
self.resize(1000, 1000)
self.rootWgt = QtGui.QWidget(self)
self.table = QtGui.QTableWidget(self.rootWgt)
self.rootWgt_lay = QtGui.QGridLayout(self.rootWgt)
self.rootWgt_lay.addWidget(self.table, 0, 0, 1, 1)
self.setCentralWidget(self.rootWgt)
self.table.setColumnCount(11)
self.table.setRowCount(111)
# all together
self.table.setItem(0, 0, QtGui.QTableWidgetItem())
self.table.item(0,0).setText(match)
for i in self.df:
for j, item in enumerate(self.df[i]):
self.table.setItem(j, i, QtGui.QTableWidgetItem())
self.table.item(j, i).setText(str(item))
#} ^ class mainWgt(QtGui.QMainWindow):
app = QtGui.QApplication(sys.argv)
gui = mainWgt()
gui.show()
sys.exit(app.exec_())
这是一个涉及 qtpy 和 pandas 的简短示例代码。
我可以使用从 anaconda64 默认下载的 windows 和 pycharm 社区版编译此代码,全部下载于 2016-04-07:
[0] 为 windows 安装 Anaconda64,而无需事先安装 python。在撰写本文时,Anaconda 默认会同时安装 3.4.3 和 3.5.1 环境。但这不会让我在接下来的步骤中感到悲伤。
[1] cmd: pip install pyinstaller, pip install 可以检测到Anaconda的python.
[2] 将软件包 "setuptools" 还原为 19.2。我在 pycharm(设置、项目:、项目解释器)中做到了这一点
[3] 按照如何使用 pyinstaller 的说明进行操作,这里的所有内容都应该 google-able
警告:结果是一个 200MB 3000+ 文件夹。如果你只是想要一个快速的 exe 来做一些小杂务,请远离大包。 Pandas 其脚本形式处于最佳状态。