How to use cx_freeze with wxPython? - windows

I can't get cx_freeze to turn the simplest wxPython app to an .exe file.
I'd like to know how to proceed.
I'm using Python 3.6.8, wxPython 4.0.4 msw (phoenix) wxWidgets 3.0.5 and Windows 10.
I've tried freezing a complex wx App, it did not work so I tried with the simplest app I could think of.
Here's my wx app :
import wx
app = wx.App()
frm = wx.Frame(None, title="Hello World")
frm.Show()
app.MainLoop()
and here's the setup for cx_freeze :
from cx_Freeze import setup, Executable
build_exe_options = {
"packages": ["os", "wx"],
"excludes": ["tkinter"]}
setup(name="simplewxapp",
version="1",
description="simplewxapp",
options={"build_exe": build_exe_options},
executables=[Executable("simplewxapp.py", base="Win32GUI")])
When I use this command : python setup.py build I expect it to work correctly (as it does when I don't use wxPython).
Instead, I get this error message :
File "C:\Program Files\Python36\lib\site-packages\win32\lib\win32verstamp.py", line 159, in stamp
h = BeginUpdateResource(pathname, 0)
pywintypes.error: (2, 'BeginUpdateResource', 'Le fichier spécifié est introuvable.')

I also tried it with cx freeze the first time. No success on my side as well! I use pyinstaller at the moment and after some tweaks it is working perfectly fine.
You can find it here: https://www.pyinstaller.org/

Related

Fuchsia OS fx set failing during build

After going through the installation steps mentioned at https://fuchsia.googlesource.com/fuchsia/+/master/docs/getting_started.md
I used the command fx set x64 which produced an error in the build/gn/preprocess_products.py file.
The error message was as shown below -
(base) xprilion#xl:~/fuchsia$ fx set x64
+ /home/xprilion/fuchsia/scripts/build-zircon.sh -v -g -t x64
+ /home/xprilion/fuchsia/zircon/prebuilt/downloads/gn gen /home/xprilion/fuchsia/out/build-zircon --root=/home/xprilion/fuchsia/zircon
Done. Made 12304 targets from 900 files in 3216ms
+ /home/xprilion/fuchsia/buildtools/gn gen /home/xprilion/fuchsia/out/x64 --check '--args=target_cpu="x64" import("//boards/x64.gni") import("//products/core.gni") if (!defined(available)) { available = [] } available+=[] if (!defined(preinstall)) { preinstall = [] } preinstall+=[] if (!defined(monolith)) { monolith = [] } monolith+=[]'
ERROR at //build/gn/packages.gni:71:26: Script returned non-zero exit code.
_preprocessed_products = exec_script("preprocess_products.py",
^----------
Current dir: /home/xprilion/fuchsia/out/x64/
Command: /usr/bin/env /home/xprilion/fuchsia/build/gn/preprocess_products.py --monolith=["garnet/packages/products/base", "garnet/packages/prod/drivers"] --preinstall=[] --available=["garnet/packages/prod/vboot_reference", "bundles/tools"]
Returned 1.
stderr:
Traceback (most recent call last):
File "/home/xprilion/fuchsia/build/gn/preprocess_products.py", line 11, in <module>
from prepreprocess_build_packages import PackageImportsResolver, PackageLabelObserver
File "/home/xprilion/fuchsia/build/gn/prepreprocess_build_packages.py", line 74
except IOError, e:
^
SyntaxError: invalid syntax
See //build/gn/BUILD.gn:7:1: whence it was imported.
import("//build/gn/packages.gni")
^-------------------------------
How to remove this error?
The answer to the above problem is simple - right now Python3.7 is not supported while building Fuchsia. I changed to Python3.6 and it worked! Python 2.7 works as well.
You are missing product information here. If you are not sure which product to chose then select core as the product at least which holds bringup component as well as minimal services needed for fuchsia to run.
$ fx set core.x64

What is Tcl and why do I need it to build applications using cx freeze and what is LSOpenURLsWithRole()?

I'm trying to build my application into an .app file and I kept hitting the following error.
[Errno 2] No such file or directory: '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl'
So I downloaded ActiveTcl8.5 and the error went away. Now I'm able to build using the following command:
python3 setup_cx_freeze.py bdist_dmg
But my application runs and immediately closes. I ran it from the cmd to get a sense as to what the error is and the only feedback I'm getting is LSOpenURLsWithRole() failed with error -10810. What am I doing wrong? Why did I need Tcl in order to use cx freeze and why does my app not want to open? This is my setup file.
import sys
from cx_Freeze import setup, Executable
build_exe_options = {"packages": ['tkinter', 'smb.SMBConnection'], "excludes": [], "includes": [], "include_files":['Project_Images', 'Project_Docs'], "bin_path_excludes": []}
setup(
name = "Test",
version = "2.51",
description = "Will this even work?",
options = {"build_exe": build_exe_options},
executables = [Executable("AccuAdmin.py")])
Tcl is a programming language, invented at roughly the same time as Python. Tkinter is a thin wrapper on top of an embedded tcl interpreter with the "tk" widget extension. You cannot use tkinter without tcl/tk.

Missing modules for cx_freeze with qgis

I try to make a exe file from a Python programm which use PyQt and QGis with cx_freeze.
Here's the setup.py used by cx_freeze.
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
options = {
'build_exe': {
'includes': ['atexit'],
'excludes': ['tkinter','tcl','tk'],
'packages': ['PyQt4.QtGui','PyQt4.Qt','qgis.core','qgis.gui','os']
}
}
executables = [
Executable('Open4.py', base=base)
]
setup(name='Open4',
version='1.1',
description='Open4 Icam',
options=options,
executables=executables
)
When I run this script, I can see this missing modules :
Missing modules:
? _emx_link imported from os
? ce imported from os
? org.python.core imported from copy
? os.path imported from Open4, ajouterunevoirie, open4__main__, os, qgis.utils, shlex
? os2 imported from os
? os2emxpath imported from os
? posix imported from os
? pwd imported from posixpath
? qgis.core.QGis imported from qgis.utils
? qgis.core.QgsApplication imported from qgis.core.contextmanagers
? qgis.core.QgsExpression imported from qgis.utils
? qgis.core.QgsFeature imported from qgis
? qgis.core.QgsGeometry imported from qgis
? qgis.core.QgsMessageLog imported from qgis.utils
? qgis.core.QgsMessageOutput imported from qgis.utils
? qgis.core.QgsProject imported from qgis.utils
? qgis.gui.QgisInterface imported from qgis.utils
? qgis.gui.QgsMapCanvas imported from ui_openihm
? qgis.server imported from qgis.utils
? riscos imported from os
? riscosenviron imported from os
? riscospath imported from os
? subprocess imported from os
but the script makes a build folder with an exe file and DLL and PYD files.
Question : cx_freeze says that qgis.core and qgis.gui are missing modules but I can see qgis._core.pyd, qgis._gui.pyd, qgis_core.dll and qgis_gui.dll in the build folder so do this modules really miss?
Now, when I try to run the EXE file, nothing appends but no error is reported even if I try to execute this EXE file in the console windows.
How can I solve this? Does it means that something (a module?) is missing?
Thank you for any help.
Philippe

Python cant see files or folders in C:\Windows\System32\GroupPolicy

I'm running into a problem where python is unable to see folders or files which do exist on the computer. I have already ensured the path has no symbolic links in it and that I have full control on the NTFS file permissions. I have even removed any hidden attributes. Below is the script I am using and its output:
import os
path = 'C:\\Windows\\System32\\GroupPolicy\\Machine'
print path
test = os.path.exists(path)
print test
C:\Windows\System32\GroupPolicy\Machine
False
I am unsure why it is returning False when I have ensured the folder does exist. If I remove "\Machine" from the path, it returns True. I have verified the following command works from a command prompt:
if exist c:\Windows\System32\GroupPolicy\Machine echo found
Any advice on how to get this working in python would be appreciated. Here is the version of python I am using:
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Alright, after some digging, found it is nothing to do with permissions but has to do with File System Redirection. As I am using the x86 version of python on a Windows x64 (using x86 as I am using py2exe), Windows is redirecting any queries on System32 and subdirectories to SysWOW64. This means I was actually querying "C:\Windows\SysWOW64\GroupPolicy\Machine" which did not exist.
To fix this, I found how to disable the File System redirection using the recipe found here: http://code.activestate.com/recipes/578035-disable-file-system-redirector/
Here is my final code which now works to disable the redirection and allows opening and querying of files in System32 on a 64 bit machine.
import ctypes
class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
def __enter__(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def __exit__(self, type, value, traceback):
if self.success:
self._revert(self.old_value)
disable_file_system_redirection().__enter__()
import os
path = 'C:\\Windows\\System32\\GroupPolicy\\Machine'
print path
test = os.path.exists(path)
print test

Why won't Firefox trace to flashlog.txt in Ubuntu?

Okay me and my friend are about to tear our hair out trying to configure the Adobe Flex SDK to work properly on our Ubuntu machine. We have installed and configured the SDK to compile ActionScript files but the FlashPlayer Debugger fails to log traces or errors to flashlog.txt when we execute the compiled swf in Firefox.
We have Flash Player Debugger installed into Firefox and a mm.cfg file located in our home directory.
Links to what we've tried:
http://www.arulraj.net/2010/08/flash-player-debugger-in-ubuntu.html
http://www.gregoryprogrammer.com/2012/12/actionscript-3-code-compilation-in-inux/
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7fc9.html
http://helpx.adobe.com/flash-player/kb/configure-debugger-version-flash-player.html
Versions of what we're using:
Firefox Browser 18.0.2
Ubuntu OS 12.0.4
Latest Flex SDK
I notice you didn't mention compiling with the -debug flag. Here're the steps I take:
Make sure you're using the debug version of the player (hit flashplayerversion.com to check). This is getting trickier in-browser, especially in 64-bit Linux. Firefox is probably easier than Chrome these days. You can also try the debug content projector (aka standalone player) located here.
Have a ~/mm.cfg file with TraceOutputFileEnable=1. Here's mine:
> cat ~/mm.cfg
ErrorReportingEnable=1
TraceOutputFileEnable=1
Use the trace method somewhere you know it will be executed:
> cat Main.as
package {
import flash.display.Sprite;
public class Main extends Sprite {
public function Main() {
trace("Hello flashlog.txt");
}
}
}
Compile the SWF with the -debug option:
mxmlc -debug Main.as
I'll test with the content projector:
>flashplayerdebugger Main.swf &
>tail ~/.macromedia/Flash_Player/Logs/flashlog.txt
Hello flashlog.txt
Or open a dedicated terminal to follow the log file as it is written:
>tail -f ~/.macromedia/Flash_Player/Logs/flashlog.txt

Resources