takluyver / pynsist

Build Windows installers for Python applications
https://pynsist.readthedocs.io/
Other
896 stars 119 forks source link

shortcut of installed program using pynsist in the start menu doesn't work! #182

Closed spaikloo closed 1 year ago

spaikloo commented 5 years ago

Hello, please help me with this issue! I'm new with Python and this is my first time I'm using the Pynsist. I wrote some code on windows 10 64x, using Python 3.6, Qt designer, PyQt5. I used Pynsist to excute it on other computers. everything seemd to look good, and the launch file is also working, but the short cut in the start menu doesn't work, it opens and close a console window very fast so I can't even read the error... this is part of my code:

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

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_()

and this is the installer.cfg I wrote:

[Application]
name=PythonApplication12
version=1.0

entry_point=test1:Ui_MainWindow
extra_preamble=PythonApplication12.py

console=true

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

[Include]

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

files = ui/test1.py
        ui/__init__.py
        ui/test1.ui
        ui
        PythonApplication12.py
        lib

Please help me and tell me where is my mistake!

takluyver commented 5 years ago

When the console window flashes and disappears, that usually means there's an error as soon as your application tries to start. The details of the error should be written to a log file:

https://pynsist.readthedocs.io/en/latest/installers.html#uncaught-exceptions

That should help you work out what's gone wrong.