Error after creating exe with Py2exe - python

Py2exe seems to run fine although it does mention that a few modules maybe missing.
I had been using the windows option (in my py2exe script) to remove the console window but realized that the process still remained open even after I closed down the gui window i.e. I could still see the process still in task manager... So I switched to using the console option and found the below error printed there. I believe this error is preventing the the app from closing. Apart from that the app runs fine.
Iv tried creating an exe from a very simple wxPython GUI app but even then I still get this error however I have no problem creating executables from apps that do not include wxPython.
Debug: src/helpers.cpp(140): 'createActCtx' failed with error 0x0000007b (the filename, directory name, or volume label syntax is incorrect.).)
Python: 2.6.6
wxPython: 2.8.11.0
Windows 7
py2exe: 0.6.9
# -*- coding: utf-8 -*-
from distutils.core import setup
import py2exe
import glob
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'email', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
'Tkconstants', 'Tkinter']
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll', 'tk84.dll',]#'msvcp90.dll']
packages = []#'wx.lib.pubsub']
data_files = [("resources", ['resources/1187958_90214884.jpg'])]
packages = ['wx.lib.pubsub',]
options = {'py2exe': {'compressed': 3,
'optimize': 2,
'excludes': excludes,
'packages': packages,
'dll_excludes': dll_excludes,
'bundle_files': 1,
'dist_dir': 'dist',
'xref': False,
'skip_archive': False,
'ascii': False,
'packages': packages,
'custom_boot_script': '',
}
}
#windows=[{'script':'gui.py'}]
for script in ["gui.py"]:
windows=[{
'script':[script]
}]
setup(options=options, console=[script], zipfile=None, data_files=data_files)

I've had very little trouble getting wxPython code to compile to an exe using py2exe. I have a tutorial that you can try here:
http://www.blog.pythonlibrary.org/2010/07/31/a-py2exe-tutorial-build-a-binary-series/
I have had some issues with the new version of pubsub that is included with 2.8.11.0. You can read the thread here: http://bit.ly/emoHEr
I ended up reverting to the previous version of wx that day mainly because I didn't have time to figure out what I was doing wrong. I don't know if that's the problem that you're having though.

Related

msi created in cx_freeze does not install program

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.

Selenium after compile py2exe, Firefox doesn't start

i wrote a BOT for a webgame, works perfectly when i run it with IDLE, firefox launches and does the job. But after compiling with Py2exe firefox doesn't launch anymore...Any ideas ?
PS : Firefox 45.0.2 , Selenium 2.53
Hum finally i solved it, was my mistake, i was copying th wedriver.xpi and webdriver_prefs.json in the wrong directory...
So you need to compile it without making a Zipfile (or won't work) and copy the 2 files in the good directory :
from : C:\Python27\Lib\site-packages\selenium\webdriver\firefox
to : /dist/selenium/webdriver/firefox
Setup.py example:
from distutils.core import setup
import py2exe
setup(
name='Web BOT',
version='1.0',
description='BOT',
author='Author',
author_email='mymail#mail.com',
url='',
windows = [{
"script":"Myscript.py",
"icon_resources": [(1, "myicon.ico")],
}],
options={
'py2exe':
{
'skip_archive': True,
'optimize': 2,
}
}
)
And then everything works fine !

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

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

py2exe strangley hanging with wxPython program using IEHtmlWindow

I have a Python 2.7.2 program with wxPython 2.8.12 and comtypes 0.6.2 dependencies on a win XP SP3 machine. I am using py2exe to produce windows distributables with the following setup:
setup(
options = {
"py2exe": {
"packages": ['wx.lib.pubsub']
}
},
windows = [
{
"script" : "entry.py",
}
],
data_files=[("bitmaps", ["../resources/icons/app_big.png",
"../resources/icons/app_medium.png",
"../resources/icons/app_small.png",
"../resources/icons/app_small_new.png",
"../resources/icons/app_small_bad.png",
"../resources/icons/cross_hover.png",
"../resources/icons/cross.png",
"../resources/icons/delete.png",
"../resources/icons/refresh.png",])]
)
I am also using the IEHtmlWindow control.
What is happening is that whenever I issue the command at the Python console, py2exe runs for a second with the following output:
running py2exe
* searching for required modules *
and then appears to hang indefinitely until I press Ctr+z.
I have tracked down the problem to the import :
from wx.lib.iewin import IEHtmlWindow
which seems to be causing the problem.
Any suggestions?
Solved, the problem was that comtypes generated a very large module file which was taking too much time to parse by py2exe:
comtypes.gen._3050F1C5_98B5_11CF_BB82_00AA00BDCE0B_0_4_0
The workaround is to patch py2exe source code (ver 0.6.9) as pointed out by Erez Bibi in his post:
http://groups.google.com/group/wxPython-users/browse_thread/thread/52deb8a0bc1cdc5e
and now with the setup file
options={
"py2exe": {
'packages': ['wx.lib.pubsub'],
'includes': ['comtypes.gen._3050F1C5_98B5_11CF_BB82_00AA00BDCE0B_0_4_0'],
'skip_scan': ['comtypes.gen._3050F1C5_98B5_11CF_BB82_00AA00BDCE0B_0_4_0']
}
},
everything seems to be working great once again.
There are actually two versions of IEHtmlWindow. You can try importing the other one:
from wx.lib.iewin_old import IEHtmlWindow
And see if that works. If it does, awesome. If not, then you should probably go cross-post to the py2exe mailing list and/or the wxPython mailing list.

Categories

Resources