Apr-07-2020, 11:50 AM
Hi everyone,
I made a python app using PyQt5, pandas, folium and stuff but now I struggle to convert it to exe. I tried Auto-to exe / Pyinstaller / Cx freeze, there is nothing to do, It doesn't work.
I decided to keep trying with cx freeze. In order to understand from where the problem come from. I will convert step by step.
At this step, the converted exe code works :
(NB : I need to add fild "plateforms" to folder to make everything work.)
simple.py :
Setup.py:
Next step, I add QWebview widget to simple.py
And now, the exe doesn't launch (I launch it, but nothing happens, no error message)
It is not related to path of map.html cause, I tried also with QUrl(www.google.com") instead of using my html file.
Do you have any idea ?
Thank you in advance.
I made a python app using PyQt5, pandas, folium and stuff but now I struggle to convert it to exe. I tried Auto-to exe / Pyinstaller / Cx freeze, there is nothing to do, It doesn't work.
I decided to keep trying with cx freeze. In order to understand from where the problem come from. I will convert step by step.
At this step, the converted exe code works :
(NB : I need to add fild "plateforms" to folder to make everything work.)
simple.py :
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 |
import sys from PyQt5.QtWebEngineWidgets import QWebEngineView from PyQt5.QtWidgets import QWidget, QMessageBox, QApplication, QLabel, QListWidget, QPushButton, QDesktopWidget, QMainWindow, QAction, qApp, QApplication, QFileDialog, QTableView, QFrame, QSplitter, QTableWidget, QTableWidgetItem, QHBoxLayout, QVBoxLayout, QGridLayout, QHeaderView, QSizePolicy, QWidget from PyQt5.QtCore import QAbstractTableModel, Qt, QSize, QUrl import os class App(QMainWindow): def __init__( self ): super ().__init__() self .title = 'TEST' self .initUI() def initUI( self ): self .setWindowTitle( self .title) self .resize( 640 , 480 ) self .widget = QWidget() self .setCentralWidget( self .widget) self .setMouseTracking( True ) self .widget.setMouseTracking( True ) self .rightClick = False self .leftClick = False self .statusBar() menubar = self .menuBar() fileMenu = menubar.addMenu( 'File' ) fileMenu2 = menubar.addMenu( 'Tools' ) fileMenu3 = menubar.addAction( 'Readme' ) self .table_view = QTableView( self .widget) self .table_view.show() self .vbox = QVBoxLayout( self .widget) self .vbox.addWidget( self .table_view) self .widget.setLayout( self .vbox) self .show() if __name__ = = '__main__' : app = QApplication(sys.argv) ex = App() sys.exit(app.exec_()) |
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 |
from cx_Freeze import setup, Executable from PyQt5.QtWebEngineWidgets import QWebEngineView from PyQt5.QtWidgets import QWidget, QMessageBox, QApplication, QLabel, QListWidget, QPushButton, QDesktopWidget, QMainWindow, QAction, qApp, QApplication, QFileDialog, QTableView, QFrame, QSplitter, QTableWidget, QTableWidgetItem, QHBoxLayout, QVBoxLayout, QGridLayout, QHeaderView, QSizePolicy, QWidget from PyQt5.QtCore import QAbstractTableModel, Qt, QSize, QUrl import os import sys path = sys.path base = None if sys.platform = = "win32" : base = "Win32GUI" if sys.platform = = 'win64' : base = "Win64GUI" packages = [ 'sys' , 'os' ] include_files = [ 'map.html' ] include = [ "PyQt5" , "atexit" ] options = { 'build_exe' : { 'packages' :packages, 'include_files' :include_files, 'includes' :include}} executables = [ Executable( 'simple.py' , base = base) ] setup(name = 'Mapping' , version = '0.1' , description = 'Visualisation de données sur une carte' , options = options, executables = executables ) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
self .webview = QWebEngineView( self .widget) def find_data_file(filename): if getattr (sys, 'frozen' , False ): datadir = os.path.dirname(sys.executable) else : datadir = os.path.dirname(__file__) return os.path.join(datadir, filename) path = find_data_file( "map.html" ) filepath = os.path.abspath(path) self .webview.load(QUrl.fromLocalFile(filepath)) self .vbox.addwidget( self .webview) |
It is not related to path of map.html cause, I tried also with QUrl(www.google.com") instead of using my html file.
Do you have any idea ?
Thank you in advance.