2014-01-08 12 views
5

Plattform ist Windows 7 64-Bit-Python 2.7 und GTK3 + installiert von http://sourceforge.net/projects/pygobjectwin32/files/?source=navbarBündelung GTK3 + mit py2exe

Die exe kompiliert wird, aber nicht ausgeführt werden, aufgrund dieser

The following modules appear to be missing 
['gi.repository.Gdk', 'gi.repository.Gtk', 'overrides.registry'] 

Wie kann ich diese Dateien richtig schließen ?

Importe in meiner Py

Datei
from gi.repository import Gtk, Gdk 

meine Setup-Datei

#!/usr/bin/env python 
from distutils.core import setup 
import py2exe, sys 
sys.path.append("C:\Python27\Lib\site-packages\gnome") 
sys.path.append("C:\Python27\Lib\site-packages\repository")#tried including these extra dirs 
sys.path.append("C:\Python27\Lib\site-packages\override")#tried including these extra dirs 
sys.path.append("C:\Python27\Lib\site-packages\gi") #tried including these extra dirs 

setup(
     options = { 
       'py2exe': { 
          'bundle_files': 1, 
          #this does not work 'includes': ['Gtk']  
          } 
       }, 
console=["gui.py"], 
zipfile=None 
) 

Die ausführbare Datei Fehler, wenn lief:

ImportError: MemoryLoadLibrary failed loading gi\_gi.pyd 

Dank

Antwort

2

habe ich nicht getestet es auf 64bit aber das ist das se tup.py Ich habe mit cx_freeze gebaut, py2exe sieht so aus als würde es lange nicht mehr gepflegt.

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-gobject-2.dll', 
       'libgdk_pixbuf-2.0-0.dll', 
       'libjpeg-8.dll', 
       'libpango-1.0-0.dll', 
       'libpangocairo-1.0-0.dll', 
       'libpangoft2-1.0-0.dll', 
       'libpangowin32-1.0-0.dll', 
       'libgnutls-26.dll', 
       'libgcrypt-11.dll', 
       'libp11-kit-0.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("main.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 
) 

auf den Bibliotheken Je Sie verwendet haben Sie möglicherweise einige fehlende dll hinzufügen müssen, am Ausgang des cx_freeze aussehen.

Ich habe das gleiche auf der Gnom Wiki vor einiger Zeit geschrieben: https://wiki.gnome.org/Projects/PyGObject#Building_on_Win32_with_cx_freeze

+0

Ich habe mit diesem spiele meine pygobject Anwendung für Windows zu bündeln, habe ich festgestellt, dass das gesamte Arbeitsverzeichnis von 50meg 180meg gewachsen ist (pygtk -> pygobject). – Naib

+0

Sie können das verkleinern. Ich habe es downto etwa 56meg bekommen – Naib

+0

Empfehlung eines anderen Tools beantwortet nicht die Frage. py2exe wird tatsächlich aktiv gepflegt, und ich habe viel mehr Probleme mit cx_freeze. – CodeMouse92

4

Sie müssen „gi“ auf „Pakete“ hinzuzufügen.

'options': { 
    'py2exe': { 
     'packages': 'gi', 
    } 
}