I want to launch a desktop application to run customer records for my sister at work,
We are actually using local storage with sqlite3, but I will switch to AWS RDS sql
The application uses these packages:
from PyQt5 import uic,QtWidgets
from reportlab.pdfgen import canvas
import sqlite3, csv
Our biggest problem is the update in the application that for each new functionality needs a new installation,
The packages I want to send in the update can contain .ui files,
I try unsuccessfully to use:
-Updater4pyi
-PyUpdater
-Esky
Esky seemingly out of phase and do not support some configurations and I believe that the tools doesn't work correctly freezing the app to .exe because de .ui files,
What is the possible solution to this issue?
Thank you in advance
Setup.py
import esky.bdist_esky
from esky.bdist_esky import Executable as Executable_Esky
from cx_Freeze import setup, Executable
include_files = ['consulta2.ui']
setup(
name = 'cadastro',
version = '1.0',
options = {
'build_exe': {
'packages': ['sqlite3','csv'],
'excludes': ['tkinter','tcl','ttk'],
'include_files': include_files,
'include_msvcr': True,
},
'bdist_esky': {
'freezer_module': 'cx_freeze',
}
},
data_files = include_files,
scripts = [
Executable_Esky(
"controle.py",
gui_only = False,
#icon = XPTO #Coloque um icone aqui se quiser ,
),
],
executables = [Executable('controle.py',base='Win32GUI')]
)
I want to execute continuos deploy,
With new functions and screens
Related
If I'm actually asking you for help, it's because I spend many hours for nothing into trying to fix my problem:
I would like to compile my python script into .exe:
(I am using Python 32 bits 3.1.4 and pygame)
I have 4 files: Class.pyc, _Class_game.pyc, _ressources.pyc et main.py
and a folder #ressources with all images and songs
This is my scritp setup.py:
import cx_Freeze
executables = [cx_Freeze.Executable("main.py"), base = "Win32GUI"]
cx_Freeze.setup(
name="Strike The square",
version = "2.0",
description = "Jeu Strike The Square, V2.1",
options={"build_exe": {"packages":["pygame"],
"include_files": ["_Class_.pyc","_Class_game.pyc","_ressources.pyc"]}},
executables = executables
)
This create a folder "exe.xin32-3.1" with python (compiled) and my game
Next, I use inno setup to build the installer and add the folder #ressources
On my computer, It works very well, but when one of my friend wants to play (he hasn't python and pygame), the game creates this error:
[Error][1]
Then...I think this error comes from windows' ressources but I don't know how can I fix it...
The option (in setup.py):
include_msvcr = True
Doesn't work...
Thanks for your answer and excuse my english...
Hawk_Eyes
PS: this my game imports
try:
import pygame,time, ctypes
from random import randint
from pygame.locals import *
from math import sqrt
from _ressources import Shared
except ImportError as e:
print("Erreur du chargement du module: {0}".format(e))
Not sure if this will help but this is a copy of my setup file, i have used this to compile Pygame, Pubnub and various things. notice i don't include the files i want to include. The setup auto finds the files needed.
import sys
from cx_Freeze import setup, Executable
exe = Executable(
script = r"launcher.py",
base = 'Win32GUI',
icon = None,
targetName = "launcher.exe"
)
setup(
version = "0.1",
description = "launcher",
author = "Joshua Nixon",
name = "launcher",
executables = [exe]
)
$ cd path/to/files
$ python file.py build
EDIT
I recently found you could create .MSI files using cx_freeze which are very nice for distributing. IF the program uses images then (because you cannot bundle images with the MSI (that i know of) you create a little function which downloads them on launch from imgur or some place))
setup.py for MSI
import sys
from cx_Freeze import setup, Executable
company_name = "JoshuaNixon"
product_name = "Test"
bdist_msi_options = {
'add_to_path': False,
'initial_target_dir': r'[ProgramFilesFolder]\%s' % (company_name),
}
if sys.platform == 'win32':
base = 'Win32GUI'
else:
base = None
exe = Executable(script='launcher.py',
base=base,
icon="mushroom.ico",
)
setup(name=product_name,
version='1.0.0',
description='blah',
executables=[exe],
options={'bdist_msi': bdist_msi_options})
$ cd path/to/files
$ python file.py bdist_msi
I am trying to convert a pyside app to an executable (.exe) on Windows using cx_freeze. The packaging works with no problem, but when starting the generated .exe file, I get the following error:
ImportError: could not import module "PySide.QtXml"
When I try to convert the app shipped with cx_Freeze\Samples\PyQt4, it runs with no problems.
In this sample application there is just a simple QDialog called, but in my application I used QtDesigner for GUI design and I load it with PySide UiLoader directly in my py.file:
class MainWindow(QtGui.QMainWindow):
def __init__(self,parent=None):
QMainWindow.__init__(self)
loader = QUiLoader()
self.ui = loader.load('xxxx.ui',self)
QMetaObject.connectSlotsByName(self)
setup.py
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
buildOptions = dict(packages = [], excludes = [])
import sys
from cx_Freeze import setup, Executable
from PySide import QtXml
base = 'Win32GUI' if sys.platform=='win32' else None
options = {
'build_exe': {
'includes': 'atexit'
}
}
build_exe_options = {
'includes': ['atexit'],
}
executables = [
Executable('xxx.py', base=base)
]
setup(name='xxx',
version = '0.10',
description = 'First try',
options = dict(build_exe = buildOptions),
executables = executables)
In my opinion there's some problem using UiLoader when converting with cx_freeze but I have no clue how to overcome this issue.
This seems to be an old question. Still I am answering as it would help someone who is looking for a solution.
The solution is so simple that you just need to add "PySide.QtXml" to the includes list. After this your setup.py will look like this
build_exe_options = {
'includes': ['atexit'],
'packages': ['PySide.QtXml'],
}
When I tried to convert my Pythonprogram into an exe with py2exe, first everything works fine until I tried to bundle all files into one single executable file. First all the images and sounds are not bundled, but in the distfolder. I have the same problem with a .dll file, witch I have to import manually for the programm to work. So how do I import all the files like images, dll's and sounds into the exe? Next when I try to execute the exe like this, it gives me this error in cmd:
Fatal Python error: (pygame parachute) Segmentation Fault
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Here is my setup file:
from distutils.core import setup
import py2exe
import Tkinter as tk
from itertools import cycle
import pygame
import random
import glob
setup(
data_files=[("libogg-0.dll"),
('.', glob.glob('*.gif')),
('.', glob.glob('*.wav'))],
options = {"py2exe": {"includes": ['Tkinter', 'random', 'itertools', 'pygame'],
"excludes": ['AppKit', 'Carbon', 'Carbon.Files', 'Foundation', 'Numeric', 'OpenGL.GL', 'OpenGL.GLU', 'RandomArray', '_scproxy', '_sysconfigdata', 'copyreg', 'dummy.Process', 'numpy', 'opencv', 'pkg_resources', 'psyco', 'queue', 'test.__main__', 'test.event_test', 'test.test_utils', 'test.test_utils.async_sub', 'test.test_utils.run_tests', 'test.test_utils.test_runner', 'test.test_utils.unittest_patch', 'urllib.parse', 'vidcap', 'win32api', 'win32con', 'win32file', 'win32pipe', 'winreg','pygame.sdlmain_osx'],
"dll_excludes": ['OLEAUT32.dll','USER32.dll', 'IMM32.dll', 'SHELL32.dll', 'ole32.dll', 'COMDLG32.dll', 'COMCTL32.dll', 'ADVAPI32.DLL', 'WS2_32.dll', 'GDI32.dll', 'WINMM.DLL', 'KERNEL32.dll', 'SDL_ttf.dll', 'libogg-0.dll'],
"packages": ['pygame'],
"bundle_files": 1,
"compressed": True
}
},
console=['test.py'],
zipfile = None
)
If there is still something unclear, feel free to comment a answer. Sorry if my english is bad.
I am working on my first Python project and I need compile with py2exe. I wrote this setup.py code :
from distutils.core import setup
import py2exe
import sys
import os
if len(sys.argv) == 1:
sys.argv.append("py2exe")
setup( options = {"py2exe": {"compressed": 1, "optimize": 2,"dll_excludes": "w9xpopen.exe",'dist_dir': "myproject", "ascii": 0, "bundle_files": 1}},
zipfile = None,
console = [
{
"script": "myapplication.py", ### Main Python script
"icon_resources": [(0, "favicon.ico")] ### Icon to embed into the PE file.
}
],)
os.system('upx -9 dist/*.exe')
os.system("rmdir /s /q build")
os.system("del /q *.pyc")
The setup code is working, but I need to change the name of the compiled application from myapplication to project.exe. What options for py2exe change the name of output application?
Add "dest_base" : "app_name" to your console dict as such:
console = [
{
"script": "myapplication.py", ### Main Python script
"icon_resources": [(0, "favicon.ico")], ### Icon to embed into the PE file.
"dest_base" : "app_name"
}]
I am trying to use cx-freeze to create a static self-contained distribution of my app (The Spye Python Engine, www.spye.dk), however, when I run cx-freeze, it says:
Missing modules:
? _md5 imported from hashlib
? _scproxy imported from urllib
? _sha imported from hashlib
? _sha256 imported from hashlib
? _sha512 imported from hashlib
? _subprocess imported from subprocess
? configparser imported from apport.fileutils
? usercustomize imported from site
This is my setup.py:
#!/usr/bin/env python
from cx_Freeze import setup, Executable
includes = ["hashlib", "urllib", "subprocess", "fileutils", "site"]
includes += ["BaseHTTPServer", "cgi", "cgitb", "fcntl", "getopt", "httplib", "inspect", "json", "math", "operator", "os", "os,", "psycopg2", "re", "smtplib", "socket", "SocketServer", "spye", "spye.config", "spye.config.file", "spye.config.merge", "spye.config.section", "spye.editor", "spye.framework", "spye.frontend", "spye.frontend.cgi", "spye.frontend.http", "spye.input", "spye.output", "spye.output.console", "spye.output.stdout", "spye.pluginsystem", "spye.presentation", "spye.util.html", "spye.util.rpc", "ssl", "stat,", "struct", "subprocess", "sys", "termios", "time", "traceback", "tty", "urllib2", "urlparse", "uuid"]
includefiles=[]
excludes = []
packages = []
target = Executable(
# what to build
script = "spye-exe",
initScript = None,
#base = 'Win32GUI',
targetDir = r"dist",
targetName = "spye.exe",
compress = True,
copyDependentFiles = True,
appendScriptToExe = False,
appendScriptToLibrary = False,
icon = None
)
setup(
version = "0.1",
description = "No Description",
author = "No Author",
name = "cx_Freeze Sample File",
options = {"build_exe": {"includes": includes,
"excludes": excludes,
"packages": packages
#"path": path
}
},
executables = [target]
)
Please note that I clearly specify the missing modules in the includes list.
How do I fix this?
Missing modules aren't necessarily a problem: a lot of modules try different imports to accommodate different platforms or different versions of Python. In subprocess, for example, you can find this code:
if mswindows:
...
import _subprocess
cx_Freeze doesn't know about this, so it will try to find _subprocess on Linux/Mac as well, and report it as missing. Specifying them in includes doesn't change anything, because it's trying to include them, but unable to find them.
It should build a file anyway, so try running that and seeing if it works.
I guess, you can not simply += on lists.
You should probably use the list method extend - otherwise the original list will not be modified:
includes.extend(["BaseHTTPServer", "<rest of your modules>"])
EDIT: (Thank #ThomasK)
+= works fine - I only had an online Python interpreter that did not work correctly. (I have no python install on my Windows installation so I had to check online).