Python 2.7 捆绑GTK3和x2B;用冷冻法

Python 2.7 捆绑GTK3和x2B;用冷冻法,python-2.7,exe,gtk3,cx-freeze,pygobject,Python 2.7,Exe,Gtk3,Cx Freeze,Pygobject,平台是Windows 7 64位,使用python 2.7和GTK3从安装 还有这里的PyGobject 我使用了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(

平台是Windows 7 64位,使用python 2.7和GTK3从安装 还有这里的PyGobject

我使用了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
)
由于此原因,exe已编译但无法运行

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.

你能帮我吗

转到gnome目录,该目录本身位于站点包目录中,并手动将所有.dll文件(不是嵌套文件)从该目录复制到构建/应用程序目录/目录。它会工作的。

你能显示一下冻结日志吗?把它放在一个小盒子里,通常很长。DLL是否位于该脚本所需的文件夹中?是否尝试设置GI_TYPELIB_路径某些DLL缺失。尝试运行python文件并在该进程上使用(
listdlls.exe test\u gtk3\u app.py>output.txt
)。从输出中检查开关库是否在输出和
c:\python27\Libs\side packages\gtk
中,然后必须在
setup.py
中编辑缺少的DLL列表。我一直在努力解决这个问题,但我使用的是python3
from gi.repository import Gtk