Image is not displayed in pyside exe file by py2exe

jatinkumar patel

I have some images in pyside dsktop application in resources folder. Here the setup.py file to make a exe file.(python setup.py py2exe)

The exe file works perfect, just image is not displaying. Is there any mistake in setup.py file?

from distutils.core import setup
from glob import glob
import py2exe

from distutils.filelist import findall
import matplotlib
import cv2
import numpy
import os

datafiles = [
        ("resources", glob('resources/*.*'))
]


datafiles.extend(matplotlib.get_py2exe_datafiles())


setup(
        console=['mainwindow.py'],
        #'file_resources': [bitmap_string[:-1]],

        options = {
                    'py2exe': {
                    'packages' : ['matplotlib'],
                    'dll_excludes': ['libgdk-win32-2.0-0.dll', 
                                     'libgobject-2.0-0.dll', 
                                     'libgdk_pixbuf-2.0-0.dll'],
                    r'includes': [r'scipy.sparse.csgraph._validation',
                                  r'scipy.special._ufuncs_cxx']
                                }
                    },
        zipfile = None,
        windows = [{
                    "script":"mainwindow.py",
                    "icon_resources":[(1, "tfr.ico")],

                    }],
        data_files = datafiles,
        )

I also tried following options in setup.py file.

"compressed": 2, "optimize": 2, "bundle_files": 1,

jatinkumar patel

I have added

datafiles.append(('imageformats', [
                'C:\Python27\Lib\site-packages\PySide\plugins\imageformats\qjpeg4.dll'
                ]))

in setup.py.

It will include qjpeg dll file which is necesary to display image file in exe.

from distutils.core import setup
from glob import glob
import py2exe

from distutils.filelist import findall
import matplotlib
import cv2
import numpy
import os

datafiles = [
        ("resources", glob('resources/*.*'))
]

**datafiles.append(('imageformats', [
                'C:\Python27\Lib\site-packages\PySide\plugins\imageformats\qjpeg4.dll'
                ]))**

datafiles.extend(matplotlib.get_py2exe_datafiles())


setup(
        console=['mainwindow.py'],
        #'file_resources': [bitmap_string[:-1]],

        options = {
                    'py2exe': {
                    'packages' : ['matplotlib'],
                    'dll_excludes': ['libgdk-win32-2.0-0.dll', 
                                     'libgobject-2.0-0.dll', 
                                     'libgdk_pixbuf-2.0-0.dll'],
                    r'includes': [r'scipy.sparse.csgraph._validation',
                                  r'scipy.special._ufuncs_cxx']
                                }
                    },
        zipfile = None,
        windows = [{
                    "script":"mainwindow.py",
                    "icon_resources":[(1, "tfr.ico")],

                    }],
        data_files = datafiles,
        )

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

"File not found" error with py2exe

From Dev

Py2Exe generate log file

From Dev

py2exe No such file or directory

From Dev

Py2exe, Tkinter, and Setup File Problems?

From Dev

Building an executable file for python code using py2exe

From Dev

py2exe - Create single executable file out of a folder

From Dev

Missing file in compiled py2exe app selenium

From Dev

Create a single-file executable using py2exe

From Dev

Python: py2exe loses file path information

From Dev

Py2Exe file closing at end, probably due to

From Dev

py2exe executes file but doesn't attempt to build

From Dev

Using third-party library in py2exe single EXE file

From Dev

Py2exe: Import error when executes created exe file

From Dev

Py2Exe: avoid windows to request permission to execute .exe file

From Dev

how to use py2exe packing python+gevent program into .exe file?

From Dev

Python: Is original source code viewable when converting a python script to .exe file using py2exe?

From Dev

unable to start exe file with pyside Qprocess

From Dev

py2exe and PyOpenGL

From Dev

"maximum recursion depth exceeded" while packaging py file with py2exe

From Dev

py2exe/pyinstaller: Is it bad practice to put all configurable variables in a .py file?

From Dev

Turning a py2exe setup.py file into one using cx_freeze

From Dev

py2exe/pyinstaller: Is it bad practice to put all configurable variables in a .py file?

From Dev

python 3.4 py2exe image.open cannot find the images

From Dev

Py2Exe, [Errno 2] No such file or directory: 'numpy-atlas.dll'

From Dev

Matplotlib in py2exe — ImportError: cannot import name dist (File "distutils\__init__.pyc")

From Dev

PyInstaller/Py2exe - include os.system call with third party scripts in single file compilation

From Dev

Can we do file handling from executable created by py2exe in Python?

From Dev

PyInstaller/Py2exe - include os.system call with third party scripts in single file compilation

From Dev

Can PhantomJS be used with py2exe?

Related Related

  1. 1

    "File not found" error with py2exe

  2. 2

    Py2Exe generate log file

  3. 3

    py2exe No such file or directory

  4. 4

    Py2exe, Tkinter, and Setup File Problems?

  5. 5

    Building an executable file for python code using py2exe

  6. 6

    py2exe - Create single executable file out of a folder

  7. 7

    Missing file in compiled py2exe app selenium

  8. 8

    Create a single-file executable using py2exe

  9. 9

    Python: py2exe loses file path information

  10. 10

    Py2Exe file closing at end, probably due to

  11. 11

    py2exe executes file but doesn't attempt to build

  12. 12

    Using third-party library in py2exe single EXE file

  13. 13

    Py2exe: Import error when executes created exe file

  14. 14

    Py2Exe: avoid windows to request permission to execute .exe file

  15. 15

    how to use py2exe packing python+gevent program into .exe file?

  16. 16

    Python: Is original source code viewable when converting a python script to .exe file using py2exe?

  17. 17

    unable to start exe file with pyside Qprocess

  18. 18

    py2exe and PyOpenGL

  19. 19

    "maximum recursion depth exceeded" while packaging py file with py2exe

  20. 20

    py2exe/pyinstaller: Is it bad practice to put all configurable variables in a .py file?

  21. 21

    Turning a py2exe setup.py file into one using cx_freeze

  22. 22

    py2exe/pyinstaller: Is it bad practice to put all configurable variables in a .py file?

  23. 23

    python 3.4 py2exe image.open cannot find the images

  24. 24

    Py2Exe, [Errno 2] No such file or directory: 'numpy-atlas.dll'

  25. 25

    Matplotlib in py2exe — ImportError: cannot import name dist (File "distutils\__init__.pyc")

  26. 26

    PyInstaller/Py2exe - include os.system call with third party scripts in single file compilation

  27. 27

    Can we do file handling from executable created by py2exe in Python?

  28. 28

    PyInstaller/Py2exe - include os.system call with third party scripts in single file compilation

  29. 29

    Can PhantomJS be used with py2exe?

HotTag

Archive