pynsist问题,我无法使应用程序从开始菜单运行

时间:2019-07-14 01:00:48

标签: python pyqt pyqt5 python-3.6 pynsist

我使用PyQt5编写了一个简单程序。我还使用了Pynsist使其在其他计算机上执行。一切都很好,但是问题是当我尝试从“开始”菜单执行应用程序时!它会打开一个控制台并快速关闭它。

我进行了长时间的搜索,我试图做别人做的事情,但是我仍然遇到同样的问题!

这是我的代码的一部分:

import os, sys
import array
import numpy as np
import matplotlib.pyplot as plt
from pandas import read_csv

## second part of import
from PyQt5 import QtWidgets, uic,QtGui,QtCore
from ui import test1
import gc


import statistics


class window(test1.Ui_MainWindow,QtWidgets.QMainWindow):
    x1=[]
    x2 = []
    h=[]
    x1_1 = []
    x1_20 = []
    x_cor = []
    x_graph = []
    x_cal = []
    x_cal_squ =[]
    x_cal_mul = []
    def __init__(self):
            super(window,self).__init__()
            self.setupUi(self)

            self.All()

    def All(self):
            self.toolButton.clicked.connect(self.select_file)
            self.pushButton.clicked.connect(self.correcting)
            self.toolButton_2.clicked.connect(self.graphic_show)
            self.pushButton_3.clicked.connect(self.checked_data)
            self.pushButton_4.clicked.connect(self.calculate)
    def select_file(self):
        if not self.lineEdit.text() == "" and not self.lineEdit_2.text() == "" and not self.lineEdit_3.text() == "":
            if self.lineEdit_3.text() == "32" or self.lineEdit_3.text() == "8":




                file,ext = QtWidgets.QFileDialog.getOpenFileName()
        # reading binary file
                count = int(os.stat(file).st_size/2)   
                statinfo = os.stat(file)

                print(statinfo,"   ",count)
                with open(file, 'rb') as fb:
                    bin_1 = array.array("h")
                    print("sss")
                    bin_1.fromfile(fb, count)


                print(len(bin_1))
                res =''
                Channel_number = int(str(self.lineEdit_3.text()))
                for x in range(1,Channel_number + 1):    # range for 32 bit. for 8 bit the range will be (1,9)
                        y = str(self.lineEdit_2.text())  # folder name
                        y_2 = str(self.lineEdit.text())  # file name
                        folder_path_1 = os.path.isdir(os.getcwd() + '/' + y +'/' + y+'{}'.format(x))
                        if not folder_path_1:
                            folder_path = os.makedirs(os.path.join(os.getcwd(), y + '/' + y +'{}'.format(x)))
        # write the data from every channle to it's folder with txt format        
                for x in range(1,Channel_number + 1):    # range for 32 bit. for 8 bit the range will be (1,9)
                        y = str(self.lineEdit_2.text())
                        folder_name = str(self.lineEdit.text())
                        folder_path_1 = os.path.isdir(os.getcwd() + '/' + y +'/' + y+'{}'.format(x))
                        if not folder_path_1:
                            folder_path = os.makedirs(os.path.join(os.getcwd(), y + '/' + y +'{}'.format(x)))

                        file_name= y_2 +'{}.txt'.format(x)
                        fig_name = y_2 +'{}.png'.format(x)
                        file_name_2 = y_2 + '_new{}.txt'.format(x)
                        fig_name_2 = y_2 + '_new{}.png'.format(x)
                        file_name_3 = 'result{}.txt'.format(x)
                        file_name_20 = y_2 + '_new20.txt'

                        with open (os.path.join(os.getcwd() + '/' + y +'/' + y+'{}'.format(x), file_name),"w") as wf:
                            res += str(x)
                            for n in range(0,len(bin_1),Channel_number):




                                if x == 20:
                                    wf.writelines("{:.2f}\n".format(bin_1[n+(x-1)]*0.65))
                                else:

                                    wf.writelines("{:.2f}\n".format(bin_1[n+(x-1)]*-0.043))

                        with open(os.path.join(os.getcwd() + '/' + y +'/' + y+'{}'.format(x), file_name),'r') as ff:
                                x1 = ff.readlines()


                                x1 = [float(i) for i in x1]
                                x1 = x1
                                x2=x1
                                x1_max = max(x1, key=abs)
                                x1_min = min(x1)

                                x1_sum = sum(x1)

                                x1_av = statistics.mean(x1)
                                x2 = [float(i) for i in x2]
                                listmask=x1_av
                                for num in range(len(x2)):

                                    if x2[num] == x1_max and num >= 0 and num <= int(len(x2)/4):
                                        #print("nummmmmm = :",num)
                                        x2[0:int(len(x2)/4)] = x2[int(3*len(x2)/4):(len(x2))]

                                    elif x2[num] == x1_max and num > int(len(x2)/4) and num <= int(len(x2))/2:
                                         x2[(num-500):(num+int(len(x2)/4))] = x2[(int(3*len(x2)/4)-500):(len(x2))]
                                    elif x2[num] == x1_max and num > int((len(x2))/2) and num <= (int(3*len(x2)/4)):
                                         x2[(num-500):(int(len(x2))-500)] = x2[0:int(len(x2)/2)]
                                         x2[(len(x2)-500):len(x2)] = x2[0:500]



                                    elif x2[num] == x1_max and num >= int(3*len(x2)/4): # and num <= (len(x2)):
                                         x2[int(3*len(x2)/4):len(x2)] = x2[0:int(len(x2)/4)]






                                print(x1_max)
                                xx1_av = statistics.mean(x2)
                                h = (x1_max - xx1_av)


                                #print( xx1_av, x1_av , h)
                                #for n in range(1,33):
                                with open("results_2.txt",'a') as test:

                                   test.writelines("{:.2f}\n".format(h*(-0.043)))

                              #  from pandas import read_csv
                                (read_csv(os.path.join(os.getcwd() + '/' + y +'/' + y+'{}'.format(x), file_name))).plot( color='red')
                                plt.savefig(os.path.join(os.getcwd() + '/' + y +'/' + y+'{}'.format(x), fig_name))
                                #plt.show()

                        with open(os.path.join(os.getcwd() + '/' + y +'/' + y+'{}'.format(x), file_name),"r")  as ff:
                            x1 = ff.readlines()
                            x1 = [float(i) for i in x1]
                            with open(os.path.join(os.getcwd() + '/' + y +'/' + y+'{}'.format(x), file_name_2),"w")  as f:
                                for num in range(len(x1)):
                                    x1[num] = (x1[num] - xx1_av)

                                    f.writelines("{:.2f}\n".format(x1[num]))
        # read the new files and write the results of max in new file for the further analysis
                del x1[:]
                gc.collect()

            else:
                QtWidgets.QMessageBox.information(None, "Error", "Make sure of the channels number!!!")
        else:
            QtWidgets.QMessageBox.information(None, "Error", "Fill all the required information")



......
if __name__ == "__main__":
    app = QtWidgets.QApplication([])
    qt_app = window()
    qt_app.show()
    app.exec_()

和installer.cfg文件:

[Application]
name=PythonApplication12
version=1.0
# How to launch the app - this calls the 'main' function from the 'PythonApplication12' package:
entry_point=test1:Ui_MainWindow
extra_preamble=PythonApplication12.py


console=true


[Python]
version=3.6.7
bitness = 64
include_msvcrt=true


[Include]
# Packages from PyPI that your application requires, one per line
# These must have wheels on PyPI:
pypi_wheels = PyQt5==5.11.3
     numpy==1.16.0
     pandas==0.23.4
     PyQt5==5.13.0
     matplotlib==3.0.2
     PyQt5-sip==4.19.18
Packages = PyQt5
     numpy
     pandas
     matplotlib
     statistics
     tkinter
     _tkinter






# Other files and folders that should be installed
files = ui/test1.py
        ui/__init__.py
        ui/test1.ui
        ui
        PythonApplication12.py
        lib

1 个答案:

答案 0 :(得分:1)

代码询问了('cycler'),然后询问了(Matplotlib需要dateutil),(六个),(pytz)...我整夜都在重新安装并将这些软件包添加到cfg文件中。所有的作品! 在另一台计算机上安装Python要容易得多!!

整个问题出在matplotlib上!