Bonjour,
j'ai récemment développé une application avec python et QT.
Voici mon application
J'aimerai faire une application compilé et j'ai vu que c'etait possible avec pyinstaller
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103 import os import urllib.request, json import sys import math from PySide2.QtWidgets import QApplication, QLabel, QProgressBar, QWidget, QTextEdit, QPushButton from PySide2 import * from time import sleep def getFile(path): return [os.path.join(r,file) for r,d,f in os.walk(path) for file in f] def updateSizePython(files): for i in range(len(files)): statinfo = os.stat(files[i]) files[i] = files[i].replace('./', '') files[i] = files[i].replace('\\', '/') files[i] = [files[i], statinfo.st_size] return files def getDataDiff(): with urllib.request.urlopen("http://update.serviceonline.fr") as url: data = json.loads(url.read().decode()) return (data) def downloadfile(file, progressBar, pourcent, textarea): oldText = textarea.toPlainText() #print('http://update.serviceonline.fr/' + file[0]) textarea.setPlainText(oldText + "[+] Téléchargement du fichier " + file[0] + "\n" ) oldText = textarea.toPlainText() url = 'http://update.serviceonline.fr/' + file[0] path = "./" dir = file[0].split("/") del dir[len(dir) - 1] for pathcut in dir: path = path + pathcut + "/" if os.path.isdir(path) == False: textarea.setPlainText(oldText + "[+] Création du dossier " + path + "\n" ) os.makedirs(path) oldText = textarea.toPlainText() try: urllib.request.urlretrieve(url, './' + file[0]) add = progressBar.value() + pourcent if progressBar.value() + pourcent >= 100: add = 100 progressBar.setProperty("value", add) textarea.setPlainText(oldText + "[+] Décompression du fichier " + file[0] + "\n") except FileNotFoundError: textarea.setPlainText(oldText + "[+] Erreur lors de la décompression du fichier " + file[0] + "\n") def start(): os.startfile("serviceOnline.exe") sys.exit(0) def runUpdate(): #sleep(1) #print("Update serviceonline") files = getFile("./") files = updateSizePython(files) textarea.setPlainText("[+] Téléchargement de l'index \n") dataremote = getDataDiff() diff = lambda l1,l2: [x for x in l1 if x not in l2] #à DL = diff(dataremote,files) #a remove = diff(files, dataremote) download = diff(dataremote,files) nbDownload = len(download) if nbDownload == 0: oldText = textarea.toPlainText() textarea.setPlainText( oldText + "[+] serviceonline est à jour \n") progressBar.setProperty("value", 100) else: for i in range(len(download)): #print (download[i]) downloadfile(download[i], progressBar, math.ceil(100 / nbDownload), textarea) btnStart.setVisible(True) if __name__ == "__main__": app = QApplication(sys.argv) windows = QWidget() windows.setFixedSize(450, 400) progressBar = QProgressBar(windows) progressBar.setGeometry(20, 10, 400, 23) progressBar.setProperty("value", 0) progressBar.setTextVisible(False) progressBar.setObjectName("progressBar") windows.setWindowTitle("Update serviceOnline") textarea = QTextEdit(windows) textarea.move(20,50) textarea.setMinimumSize(400,100) textarea.setReadOnly(1) btnStart = QPushButton('Lancer serviceonline',windows) btnStart.setVisible(False) btnStart.move(20,260) btnStart.connect(btnStart, QtCore.SIGNAL('clicked()'), start) windows.show() QtCore.QTimer.singleShot(500, runUpdate) sys.exit(app.exec_())
j'ai donc exécuté la commande suivante
Quand je souhaite lancé mon update.exe , la console souvre quelques secondes et se ferme ... impossible de lire l'erreur (en double cliquant dessous ou l'executant avec CMD)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 pyinstaller --paths="C:\Users\baptiste\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\shiboken2" --paths="C:\Users\baptiste\AppData\Local\Programs\P ython\Python37-32\Lib\site-packages\PySide2" --name="TestApp" --onedir --windowed --noconsole .\update.py
Pouvez vous m'aider ? c'est la premiere fois que je fait une compilation d'un programme python
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 raceback: Pyinstaller --paths="C:\Users\baptiste\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\shiboken2" --paths="C:\Users\baptiste\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\PySide2" .\update.py 45 INFO: PyInstaller: 3.5.dev0+cb8d10af6 45 INFO: Python: 3.7.2 45 INFO: Platform: Windows-10-10.0.17763-SP0 46 INFO: wrote D:\ProjetUpdater\update.spec 48 INFO: UPX is not available. 49 INFO: Extending PYTHONPATH with paths ['D:\ProjetUpdater', 'C:\Users\baptiste\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\shiboken2', 'C:\Users\baptiste\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\PySide2', 'D:\ProjetUpdater'] 49 INFO: checking Analysis 49 INFO: Building Analysis because Analysis-00.toc is non existent 50 INFO: Initializing module dependency graph... 52 INFO: Initializing module graph hooks... 54 INFO: Analyzing base_library.zip ... 2720 INFO: running Analysis Analysis-00.toc 2722 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable required by c:\users\baptiste\appdata\local\programs\python\python37-32\python.exe 3801 INFO: Caching module hooks... 13704 INFO: Analyzing D:\ProjetUpdater\update.py 13892 INFO: Loading module hooks... 13892 INFO: Loading module hook "hook-encodings.py"... 13962 INFO: Loading module hook "hook-pydoc.py"... 13963 INFO: Loading module hook "hook-PySide2.py"... 13964 WARNING: Hidden import "numpy.core.multiarray" not found! 13965 INFO: Loading module hook "hook-PySide2.QtNetwork.py"... 14064 INFO: Loading module hook "hook-PySide2.QtWidgets.py"... 14065 INFO: Loading module hook "hook-xml.py"... 14113 INFO: Loading module hook "hook-PySide2.QtCore.py"... 14188 INFO: Loading module hook "hook-PySide2.QtGui.py"... 14722 INFO: Looking for ctypes DLLs 14722 INFO: Analyzing run-time hooks ... 14726 INFO: Including run-time hook 'pyi_rth_qt5plugins.py' 14731 INFO: Looking for dynamic libraries 24710 INFO: Looking for eggs 24711 INFO: Using Python library c:\users\baptiste\appdata\local\programs\python\python37-32\python37.dll 24712 INFO: Found binding redirects: [] 24722 INFO: Warnings written to D:\ProjetUpdater\build\update\warn-update.txt 24759 INFO: Graph cross-reference written to D:\ProjetUpdater\build\update\xref-update.html 24780 INFO: checking PYZ 24780 INFO: Building PYZ because PYZ-00.toc is non existent 24782 INFO: Building PYZ (ZlibArchive) D:\ProjetUpdater\build\update\PYZ-00.pyz 25316 INFO: Building PYZ (ZlibArchive) D:\ProjetUpdater\build\update\PYZ-00.pyz completed successfully. 25330 INFO: checking PKG 25330 INFO: Building PKG because PKG-00.toc is non existent 25330 INFO: Building PKG (CArchive) PKG-00.pkg 25345 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully. 25347 INFO: Bootloader c:\users\baptiste\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe 25347 INFO: checking EXE 25349 INFO: Building EXE because EXE-00.toc is non existent 25350 INFO: Building EXE from EXE-00.toc 25351 INFO: Appending archive to EXE D:\ProjetUpdater\build\update\update.exe 25408 INFO: Building EXE from EXE-00.toc completed successfully. 25415 INFO: checking COLLECT 25415 INFO: Building COLLECT because COLLECT-00.toc is non existent 25415 INFO: Building COLLECT COLLECT-00.toc 26199 INFO: Building COLLECT COLLECT-00.toc completed successfully. PS D:\ProjetUpdater>
Partager