msi created in cx_freeze does not install program - python

I have a python program I've created and turned into an exe with cx_freeze. When just creating the exe with "python setup.py build", everything works great. Now I am trying to create an installer for it by using "python setup.py bdist_msi" and everything seems to work great at first.
The installer pops up and asks me to select a directory. After clicking next, Windows requires me to accept that I'm installing from an unknown publisher. After accepting, the next page immediately jumps to "Completing the (program) installer", and "click finish to exit the installer". After clicking finish, I cannot find my program file anywhere, and the installer appeared to do nothing.
I've tried running this on multiple computers, and nothing seems to work. I think this is an issue with my setup.py script. This does include several qml files and some pictures in my "Resources" folder, and there are several csv's in my "Data-and-executable" folder, plus a exe that is called on by my python script.
from cx_Freeze import setup, Executable
# dependencies
build_exe_options = {
"packages": ['atexit', "os", "sys", "csv", "time", "functools", "PySide2.QtCore", "PySide2.QtWidgets", "PySide2.QtUiTools", "PySide2.QtQuick", "PySide2.QtQml", "PySide2.QtGui", "shiboken2"],
"include_files": ['README.md', r'Resources','inputClass.py', 'selections.py','simulationOutput.py',
'Data-and-executable'],
"include_msvcr": True,
"excludes": ["Tkinter", "Tkconstants", "tcl", ],
"build_exe": "build",
}
bdist_msi_options = {
'add_to_path': False,
'initial_target_dir': r'[ProgramFilesFolder]\%s\%s' % ("Name", "Product"),
}
executable = [
Executable("main.py",
base="Win32GUI",
targetName="product.exe",
icon= r"Resources\logo_icon.ico"
)
]
setup(name = "Product",
version = "0.3",
description = "Simulator",
options={"bdist_msi": bdist_msi_options,
"build_exe": build_exe_options},
executables=executable
)
There are no error messages or anything else to tip me off as to what's going on. Even calling my .msi with cmd does not provide any insight.

Smh. I had all of my files just in the "build" folder, and not the "build/exe.win-amd64-3.6" folder. It works.

Related

cx_Freeze doesn't print to console

I have an application that prints a few things to the console upon running. But as a standalone the executable doesn't print anything to the console?
The setup.py script looks like this:
import sys
from cx_Freeze import setup, Executable
setup(
name = "My App",
version = "1.0",
options = {
"build_exe" : {
"include_files": ['MyImgs']
},
},
executables = [Executable("Main.py", base = "Win32GUI")]
)
On the command line I run the following: py setup.py build
I then find the executable and run: Main.exe.
What I am missing for some reason is any print() statements. Is there something I need to include in the setup script for this to happen?
If you use the "Win32GUI" base, then Windows does not make available stdout and stderr. You will need to redirect those yourself to some other location (such as a file). If you use the "Console" base then stdout and stderr are available and print() will work as expected -- but you will see a console created for you if you haven't run it from a console in the first place!

Is it possible to use cx_freeze on a python 3 project using the pip module?

I am writing an installation program for a larger program I am writing, and I am using CxFreeze to convert it to an executable file, however, when I run the .exe file, it crashes with the line "import pip", and brings up (as shown below), so basically my question is: Is it possible to use CxFreeze on an application with pip imported?
Edit:
Here are all the files I am using:
setup.py (V1):
from cx_Freeze import *
import os, pip
setup(name=("ARTIST"),
version = "1",
description = "ARTIST installation file",
executables = [Executable("Install ARTIST.py"), Executable("C:\\Python34\\Lib\\site-packages\pip\\__init__.py")],
)
This brings up the error:
setup.py (V2):
from cx_Freeze import *
import os, pip
setup(name=("ARTIST"),
version = "1",
description = "ARTIST installation file",
executables = [Executable("Install ARTIST.py"],
options = {"build_exe": {"packages":[pip]}}
)
This brings up an error in the setup.bat file:
Edit:
If anyone wants to look at the website where I am publishing the larger program, here is the link:
alaricwhitehead.wix.com/artist
Edit2:
this is the error i get when i use py2exe:
Edit3:
here is a copy of the code:
https://www.dropbox.com/s/uu46iynm8fr8agu/Install%20ARTIST.txt?raw=1
please note: I didn't want to have to post a link to it, but it was too long to post directly.
The are two problems in your setup script. The first problem is that you specified extra modules to include in your frozen application under the packages option of the build_exe command: packages is for specifying which packages of your application you need to include, for the external modules (such as pip) you need to use includes. The second problem is that you need to pass to includes a list of strings of modules and not the module itself:
setup(
name=("ARTIST"),
version="1",
description="ARTIST installation file",
options={
'build_exe': {
'excludes': [], # list of modules to exclude
'includes': ['pip'], # list of extra modules to include (from your virtualenv of system path),
'packages': [], # list of packages to include in the froze executable (from your application)
},
},
executables=[
Executable(
script='run.py', # path to the entry point of your application (i.e: run.py)
targetName='ARTIST.exe', # name of the executable
)
]
)

Creating an Exe with Selenium Module: Py2exe/Pyinstaller

I've looked everywhere. Stackoverflow, various messageboards, the py2exe website, the pyinstaller website...nothing is helping. Including the selenium module, particularly making an exe that supports firefox, seems impossible. I am starting to pull out my hair because using either py2exe and pyinstaller is becoming a huge headache.
Both py2exe and pyinstaller have their share of problems.
My goal is to make one single exe file, without any extra directories, so that other people can use my program if they do not have python/modules.
With py2exe, if I create a setup.py file as such
from distutils.core import setup
import py2exe
setup(
name='Ask Alfred',
data_files = [('Drivers', ['Drivers/chromedriver.exe',
'Drivers/webdriver.xpi','Drivers/webdriver_prefs.json'])],
version='1.0',
description='Find emails fast!',
author='Me',
windows=[{'script': 'alphy.py'}],
options={
'py2exe':
{
'skip_archive': False,
'optimize': 2,
}
}
)
it will create an exe in the dist folder and a Drivers folder with the files I need, however, if I try to run the exe it will tell me that it could not find these files (because it is looking for them in the library.zip folder). On top of that, my GUI looks terrible (fonts are now grey instead of black and images with white backgrounds now have grey backgrounds).
With pyinstaller, if I use the "--onefile" flag when creating the exe it does not work at all/neither firefox nor chrome gets started.
With either, I only get workable results if I choose to not archive/not make one file. In that case, pyinstaller delivers a fully working solution.
Try this:
options={
'py2exe':
{
'skip_archive': True,
'unbuffered': True,
'bundle_files': 2, #assuming you dont want to include the python interpreter
'optimize': 2,
},
},
zipfile = None

I need help converting .py file to .exe file

I am trying to convert a .py file to .exe file using cx-freeze. I have installed cx-freeze and have added python to my computer path. However, Using the code below, i am supposed to locate the qwindows.dll file in python33. I can't seem to find the file, not only that, i cant seem to find the platforms folder. I have tried uninstalling pyqt4 and reinstalling it using an installer and also installing pyqt5. I still cant find the folder/file...Nothing works??!!!
The code i used is here:
import sys
from cx_Freeze import setup, Executable
base = "Win64GUI"
path_platforms = ( "C:\Python33\Lib\site-packages\PyQt4\plugins\platforms\qwindows.dll", "platforms\qwindows.dll" )###Find directory of qwindows.dll###
build_options = {"includes" : [ "re", "atexit" ], "include_files" : [ path_platforms ]}
setup(
name = "Starters 'R' Us", ###Janu change your name here###
version = "0.1",
description = "Maths Assessment System",
options = {"build_exe" : build_options},
executables = [Executable("MyProgram.py", base = base,shortcutName="Starters 'R' Us",shortcutDir="DesktopFolder")]###Change the .py file to yours.###
)
###the shortcut creates shortcut on your desktop###

Compiling a python script I've written as an .exe and .app

To preface, I have very little python knowledge, so the simplest solution will probably be the best one.
Essentially, I've written a program that takes user input and writes it to a text file. I've created a GUI with Qt and PySide. What I want to do now is to compile everything together to be a single .exe file that I can just drop into the laps of anyone who wants to use it. Basically, it needs to be able to run out of 1 single .exe file on a computer that doesn't necessarily have any of the python libraries installed that mine does.
The only imports on the program are
import sys
from PySide.QtCore import *
from PySide.QtGui import *
from math import *
in case those are important to the compiling. Thank you for the help, I appreciate it.
P.S. It's for my grandmother, who has nearly no knowledge of computers whatsoever. If possible, it'd be awesome if it would just...open. I don't mind if it has to run something in cmd to install all the python stuff, as long as the .exe from which the program runs is still JUST an .exe.
I suspect your grandmother uses windows in which case I would recommend using py2exe.
Here is probably all than you need...
1). create the below script and modify the last line of it to be the name of the actual script (see its last line)
#execmaker.py would be the name of this file
#stable version
from distutils.core import setup
import py2exe
includes = []
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
'Tkconstants', 'Tkinter']
packages = []
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll',
'tk84.dll']
setup(
options = {"py2exe": {"compressed": 2,
"optimize": 2,
"includes": includes,
"excludes": excludes,
"packages": packages,
"dll_excludes": dll_excludes,
"bundle_files": 3,#dont bundle else unstable
"dist_dir": "dist",
"xref": False,
"skip_archive": False,
"ascii": False,
"custom_boot_script": '',
}
},
windows=['My_Script.py'] #this is the name of your actual script
)
2). Then you can go to the directory where this script and your actual script resides via cmd and then type
python execmaker.py py2exe
You now should have a working executable. Now a you can double click on the executable and your script will run. oh yeah and if you have questions follow this guy's instructions...he is good!
http://www.blog.pythonlibrary.org/2010/07/31/a-py2exe-tutorial-build-a-binary-series/
download pyinstaller (http://www.pyinstaller.org/)
open your cmd prompt
cd folder
c:\pyinstaller\pyinstaller.py --noconsole --onefile my_script.py
the exe should be found in the dist folder that is created

Categories

Resources