3

Platform is Windows 7 64bit using python 2.7 and GTK3 installed from http://games.2g2s.de/?page_id=223 and PyGobject from here http://sourceforge.net/projects/pygobjectwin32/files/?source=navbar

I used the script provided on wiki:

from cx_Freeze import setup, Executable
import os, site, sys

## Get the site-package folder, not everybody will install
## Python into C:\PythonXX
site_dir = site.getsitepackages()[1]
include_dll_path = os.path.join(site_dir, "gtk")

## Collect the list of missing dll when cx_freeze builds the app
missing_dll = ['libgtk-3-0.dll',
           'libgdk-3-0.dll',
           'libatk-1.0-0.dll',
           'libcairo-2.dll',
           'libcairo-gobject-2.dll',
           'libgdk_pixbuf-2.0-0.dll',
           'libpango-1.0-0.dll',
           'libpangocairo-1.0-0.dll',
           'libpangoft2-1.0-0.dll',
           'libpangowin32-1.0-0.dll',
           'libffi-6.dll',
           'libfontconfig-1.dll',
           'libfreetype-6.dll',
           'libgio-2.0-0.dll',
           'libglib-2.0-0.dll',
           'libgmodule-2.0-0.dll',
           'libgobject-2.0-0.dll',
           'libpng15-15.dll',
          ]

## We also need to add the glade folder, cx_freeze will walk
## into it and copy all the necessary files
glade_folder = 'glade'

## We need to add all the libraries too (for themes, etc..)
gtk_libs = ['etc', 'lib', 'share']

## Create the list of includes as cx_freeze likes
include_files = []
for dll in missing_dll:
    include_files.append((os.path.join(include_dll_path, dll), dll))

## Let's add glade folder and files
include_files.append((glade_folder, glade_folder))

## Let's add gtk libraries folders and files
for lib in gtk_libs:
    include_files.append((os.path.join(include_dll_path, lib), lib))

base = None

## Lets not open the console while running the app
if sys.platform == "win32":
    base = "Win32GUI"

executables = [
    Executable("materii.py",
               base=base
    )
]

buildOptions = dict(
    compressed = False,
    includes = ["gi"],
    packages = ["gi"],
    include_files = include_files
    )

setup(
    name = "test_gtk3_app",
    author = "Gian Mario Tagliaretti",
    version = "1.0",
    description = "GTK 3 test",
    options = dict(build_exe = buildOptions),
    executables = executables
)

The exe is compiled but fails to run, due to this

Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", in <module>
    exec code in m.__dict__
  File "materii.py", line 2, in <module>
  File "C:\Python27\lib\site-packages\gi\__init__.py", line 27, in <module>
    from ._gi import _API
  File "ExtensionLoader_gi__gi.py", line 22, in <module>
  File "ExtensionLoader_gi__gi.py", line 14, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.

Line 2 from materii.py is

from gi.repository import Gtk

Can you help me please?

D.Andreea
  • 41
  • 2
  • Can you show the log from freezing it? Put it into a pastebin, it's usually long. Are the DLLs in the folder where that script expects them? – Thomas K Mar 03 '14 at 18:17
  • have you tried setting GI_TYPELIB_PATH – Naib Mar 05 '14 at 18:54
  • Some dlls are missing there. Try running the python file and use [ListDLLs.exe](http://technet.microsoft.com/sk-sk/sysinternals/bb896656.aspx) on that process (`listdlls.exe test_gtk3_app.py > output.txt`). And from the output check the witch libraries are in the output and in the `c:\python27\Libs\side-packages\gtk` and then you must edit the missing_dlls list in the `setup.py`. I have struggled with this but I was using **python3** – microo8 Mar 11 '14 at 14:03

1 Answers1

3

Go to the gnome dir, which by itself is in the site-packages dir and manually copy all the .dll files (not the nested one) from this dir to your build/your-application-dir/ dir. And it will work.

Mahan Marwat
  • 373
  • 1
  • 13