Problems compiling python3 and pyqt4 with cx_freeze

I am trying to compile a simple script I wrote using Python3 and PyQt4 using cx_Freeze, but I have three problems that I just cannot figure out.

  • I cannot get badges. I am using a compiled resource file for it, i.e. importing a .py containing resources, and I tried to follow the guidelines here by copying the imageformats folder to my project folder, but nothing works.

  • I am not using severl python modules including tcl and ttk, so I added them to the parameter excludes

    . However, they still seem to have been added.

  • When I try to compile with base='Win32GUI'

    running the generated exe, an exception is thrown:'NoneType' has no attribute 'encoding'

I'm pretty sure there is something wrong in my setup script because the cx_Freeze documentation isn't very verbose, so hopefully someone can point out the problem. Here is the setup script. I am not going to post the script, I am compiling because it is quite long, but if necessary, I will try to create a short version for testing.

from cx_Freeze import setup, Executable

exe = Executable(
    script='cconvert.py',
    base='Win32GUI'
)

options = dict(
    excludes=['curses', 'email', 'tcl', 'ttk']
)

setup(
    name="Coord Convertor",
    version="0.1",
    description="A Coordinate converter from DMS to DD",
    requires=['pyqt4 (>=4.8)', 'dtlibs (>=0.4.1)'],
    data_files=['imageformats'],
    executables=[exe],
    options={'build-exe': options}
)

      

+3


source to share


2 answers


(Note that around 1.)

2: In options = {'build-exe' ..., I think it should be build_exe (underscore instead of dash).



3: Are you trying to access something like sys.stdout.encoding

anywhere? sys.stdout

will be absent when using the Win32GUI base. Even a challenge print()

can cause this.

+3


source


solvable. In addition to Thomas' pointers, I need "images" to be in "include files" in parameters, not "data_files". My final script looks like this:



from cx_Freeze import setup, Executable

exe = Executable(
    script='cconvert.pyw',
    base='Win32GUI'
)

options = dict(
    excludes=['curses', 'email', 'tcl', 'ttk', 'tkinter'],
    include_files=['imageformats']
)

setup(
    name="Coord Convertor",
    version="0.1",
    description="A Coordinate converter from DMS to DD",
    requires=['pyqt4 (>=4.8)', 'dtlibs (>=0.4.1)'],
    executables=[exe],
    options={'build_exe': options}
)

      

+6


source







All Articles