免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: bleem1998
打印 上一主题 下一主题

pygtk做了个游戏,还没完成,迫不及待给大家看啦 :D [复制链接]

论坛徽章:
0
11 [报告]
发表于 2006-02-13 15:15 |只看该作者
PY2.4及上面提供的版本,
我干脆把BIN下的所有DLL库都COPY到system32下了,这下不提示了,不过出现其他问题

论坛徽章:
0
12 [报告]
发表于 2006-02-13 15:24 |只看该作者
D:\python\zhfsj>python go.py
go.py:13: PangoWarning: No builtin or dynamically loaded modules
were found. Pango will not work correctly. This probably means
there was an error in the creation of:
  'C:\WINNT\system32\etc\pango\pango.modules'
You may be able to recreate this file by running pango-querymodules.
  xml = gtk.glade.XML('zhfsj.glade')
go.py:13: PangoWarning: _pango_engine_shape_shape: assertion `PANGO_IS_FONT (fon
t)' failed
  xml = gtk.glade.XML('zhfsj.glade')

g.gif (13.22 KB, 下载次数: 84)

g.gif

论坛徽章:
0
13 [报告]
发表于 2006-02-13 17:24 |只看该作者
原帖由 jejwe 于 2006-2-13 15:24 发表
D:\python\zhfsj>python go.py
go.py:13: PangoWarning: No builtin or dynamically loaded modules
were found. Pango will not work correctly. This probably means
there was an error in the creation ...


我的安装过程是这样的:
1. gtk-win32-2.8.10-rc1.exe
http://gladewin32.sourceforge.net/

2. pycairo-1.0.2-1.win32-py2.4.exe
3. pygtk-2.8.4-1.win32-py2.4.exe
http://www.mapr.ucl.ac.be/~gustin/win32_ports/

[ 本帖最后由 wolfg 于 2006-2-13 17:29 编辑 ]

论坛徽章:
0
14 [报告]
发表于 2006-02-13 18:06 |只看该作者
我打出来的包也出现和jejwe一样的错误

论坛徽章:
0
15 [报告]
发表于 2006-02-13 20:13 |只看该作者
原帖由 bleem1998 于 2006-2-13 18:06 发表
我打出来的包也出现和jejwe一样的错误

参考一下这个
http://www.async.com.br/faq/pygt ... ;file=faq21.002.htp

会不会是因为缺libglade?

论坛徽章:
0
16 [报告]
发表于 2006-02-13 22:45 |只看该作者
估计不是
dist目录下有libglade-2.0-0.dll

搜索了一下错误信息
网上也有人遇到
解决办法是删除libpango-1.0-0.dll这个文件
程序就正常运行了
可是打包确实没有成功
拿到别的机器上用不了

论坛徽章:
0
17 [报告]
发表于 2006-02-14 13:12 |只看该作者
py2exe打包后的程序运行还是得需要GTK的runtime library
看这里
http://starship.python.net/crew/theller/moin.cgi/Py2exeAndPyGTK
的最后一段

可以把GTK的runtime library用InnoSetup一起打包制成安装程序

论坛徽章:
0
18 [报告]
发表于 2006-02-14 16:00 |只看该作者
我修改过的setup.py

需要先安装InnoSetup
isetup-5.1.6.exe
http://www.jrsoftware.org/isdl.php
ChineseSimp-11-5.1.0.isl
http://www.jrsoftware.org/files/istrans/

最好也有安装python的ctypes模块
http://starship.python.net/crew/theller/ctypes/

假设GTK已经安装在C:\GTK
Gtk+/Win32 Runtime Environment Installer 2.8.10-rc1 (.exe, 5.21M)
http://gladewin32.sourceforge.net/modules/wfdownloads/visit.php?lid=97

  1. # setup.py
  2. # -*- coding: cp936 -*-
  3. # Author: wolfg

  4. # A setup script showing how to extend py2exe.
  5. #
  6. # In this case, the py2exe command is subclassed to create an installation
  7. # script for InnoSetup, which can be compiled with the InnoSetup compiler
  8. # to a single file windows installer.
  9. #
  10. # By default, the installer will be created as dist\Output\setup.exe.

  11. from distutils.core import setup
  12. import py2exe
  13. import sys
  14. import glob

  15. ################################################################
  16. # arguments for the setup() call

  17. livinginzhuhai = dict(
  18.     script = "go.py",
  19.     #other_resources = [],
  20.     #icon_resources = [(1, "check.ico")],
  21.     dest_base = r"bin\go")

  22. zipfile = r"lib\shardlib"

  23. options = {"py2exe":
  24.             {
  25.               "compressed": 1,
  26.               "optimize": 2,
  27.               "packages": "encodings",
  28.               "includes": "cairo, pango, pangocairo, atk, gobject",            
  29.             }
  30.           }

  31. ################################################################
  32. import os

  33. GTKDIR = 'C:\\gtk\\'
  34. os.environ['PATH'] += ";%s/lib;%s/bin" % (GTKDIR, GTKDIR)

  35. GTK_RUNTIME_FILES = glob.glob(GTKDIR + 'etc\\*\\*')

  36. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'lib\\*.a')
  37. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'lib\\*.alias')
  38. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'lib\\*.lib')
  39. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'lib\\glib-2.0\\include\\*.*')
  40. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'lib\\gtk-2.0\\2.4.0\\*\\*.*')
  41. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'lib\\gtk-2.0\\include\\*.*')
  42. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'lib\\gtkglext-1.0\\include\\*.*')
  43. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'lib\\libglade\\2.0\\include\\*.*')
  44. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'lib\\pango\\1.4.0\\modules\\*.*')
  45. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'lib\\pkgconfig\\*.*')

  46. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'share\\aclocal\\*')
  47. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'share\\xml\\libglade\\*')
  48. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'share\\pixmaps\\*.png')
  49. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'share\\pixmaps\\glade-2\\*.png')
  50. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'share\\locale\\zh_CN\\*\\*')
  51. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'share\\themes\\Default\\*\\*')
  52. GTK_RUNTIME_FILES += glob.glob(GTKDIR + 'share\\themes\\MS-Windows\\*\\*')

  53. class InnoScript:
  54.     def __init__(self,
  55.                  name,
  56.                  install_dir,
  57.                  lib_dir,
  58.                  dist_dir,
  59.                  windows_exe_files = [],
  60.                  lib_files = [],
  61.                  version = "1.0",
  62.                  output_basename = "Setup"):
  63.         self.lib_dir = lib_dir
  64.         self.dist_dir = dist_dir
  65.         if not self.dist_dir[-1] in "\\/":
  66.             self.dist_dir += "\\"
  67.         self.name = name
  68.         self.install_dir = install_dir
  69.         self.version = version
  70.         self.output_basename = output_basename
  71.         self.windows_exe_files = [self.chop(p) for p in windows_exe_files]
  72.         self.lib_files = [self.chop(p) for p in lib_files]
  73.         

  74.     def chop(self, pathname):
  75.         assert pathname.startswith(self.dist_dir)
  76.         return pathname[len(self.dist_dir):]
  77.    
  78.     def create(self, pathname="dist\\livinginzhuhai.iss"):
  79.         self.pathname = pathname
  80.         ofi = self.file = open(pathname, "w")
  81.         print >> ofi, "; WARNING: This script has been created by py2exe. Changes to this script"
  82.         print >> ofi, "; will be overwritten the next time py2exe is run!"
  83.         print >> ofi, r"[Setup]"
  84.         print >> ofi, r"AppName=%s" % self.name
  85.         print >> ofi, r"AppVerName=%s %s" % (self.name, self.version)
  86.         print >> ofi, r"DefaultDirName={pf}\%s" % self.install_dir
  87.         print >> ofi, r"DefaultGroupName=%s" % self.name
  88.         print >> ofi, r"Compression=lzma"
  89.         print >> ofi, r"SolidCompression=yes"
  90.         print >> ofi, r"OutputBaseFilename=%s" % self.output_basename
  91.         print >> ofi

  92.         print >> ofi, r"[Files]"
  93.         for path in self.windows_exe_files + self.lib_files:
  94.             print >> ofi, r'Source: "%s"; DestDir: "{app}\%s"; Flags: ignoreversion' % (path, os.path.dirname(path))        
  95.         
  96.         for src, dest in [(p, p[len(GTKDIR):]) for p in GTK_RUNTIME_FILES]:
  97.           print >> ofi, r'Source: "%s"; DestDir: "{app}\%s"; Flags: ignoreversion' % (src, os.path.dirname(dest))
  98.         print >> ofi
  99.         
  100.         print >> ofi, r"[Tasks]"
  101.         print >> ofi, r'Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked'
  102.         print >> ofi
  103.         
  104.         print >> ofi, r"[Icons]"
  105.         for path in self.windows_exe_files:
  106.             print >> ofi, r'Name: "{group}\%s"; Filename: "{app}\%s"; WorkingDir: "{app}\%s"' % \
  107.                   (self.name, path, os.path.dirname(path))
  108.         print >> ofi, r'Name: "{group}\Uninstall %s"; Filename: "{uninstallexe}"' % self.name        
  109.         print >> ofi, r'Name: "{userdesktop}\%s"; Filename: "{app}\bin\go.exe"; Tasks: desktopicon; WorkingDir: "{app}\bin"' % self.name
  110.         print >> ofi
  111.         
  112.         print >> ofi, r"[Run]"
  113.         print >> ofi, r'Filename: "{app}\bin\go.exe"; Description: "%s"; Flags: postinstall shellexec skipifsilent' % (u'开始“珠海浮生记”').encode('cp936')
  114.         print >> ofi
  115.         
  116.         print >> ofi, r"[Languages]"
  117.         print >> ofi, r'Name: "cn"; MessagesFile: "C:\Program Files\Inno Setup 5\Languages\ChineseSimp.isl"'
  118.         print >> ofi
  119.         
  120.     def compile(self):
  121.         try:
  122.             import ctypes
  123.         except ImportError:
  124.             try:
  125.                 import win32api
  126.             except ImportError:
  127.                 import os
  128.                 os.startfile(self.pathname)
  129.             else:
  130.                 print "Ok, using win32api."
  131.                 win32api.ShellExecute(0, "compile",
  132.                                                 self.pathname,
  133.                                                 None,
  134.                                                 None,
  135.                                                 0)
  136.         else:
  137.             print "Cool, you have ctypes installed."
  138.             res = ctypes.windll.shell32.ShellExecuteA(0, "compile",
  139.                                                       self.pathname,
  140.                                                       None,
  141.                                                       None,
  142.                                                       0)
  143.             if res < 32:
  144.                 raise RuntimeError, "ShellExecute failed, error %d" % res


  145. ################################################################

  146. from py2exe.build_exe import py2exe

  147. class build_installer(py2exe):
  148.     # This class first builds the exe file(s), then creates a Windows installer.
  149.     # You need InnoSetup for it.
  150.     def run(self):
  151.         # First, let py2exe do it's work.
  152.         py2exe.run(self)

  153.         lib_dir = self.lib_dir
  154.         dist_dir = self.dist_dir
  155.         
  156.         # create the Installer, using the files py2exe has created.
  157.         script = InnoScript(u"珠海浮生记".encode('cp936'),
  158.                             u"珠海浮生记".encode('cp936'),
  159.                             lib_dir,
  160.                             dist_dir,
  161.                             self.windows_exe_files,
  162.                             self.lib_files,
  163.                             '1.0',
  164.                             output_basename="Setup"
  165.                             )
  166.         print "*** creating the inno setup script***"
  167.         script.create()
  168.         print "*** compiling the inno setup script***"
  169.         script.compile()
  170.         # Note: By default the final setup.exe will be in an Output subdirectory.

  171. ################################################################

  172. setup(
  173.     options = options,
  174.     # The lib directory contains everything except the executables and the python dll.
  175.     zipfile = zipfile,
  176.     windows = [livinginzhuhai],
  177.     # use out build_installer class as extended py2exe build command
  178.     cmdclass = {"py2exe": build_installer},
  179.     data_files=[("bin", ["zhfsj.glade", ])]
  180.     )
复制代码

[ 本帖最后由 wolfg 于 2006-2-14 16:05 编辑 ]

论坛徽章:
0
19 [报告]
发表于 2006-02-14 19:19 |只看该作者
出现这个错误

  1. D:\zhfsj>python setup.py py2exe
  2. running py2exe
  3. *** searching for required modules ***
  4. Traceback (most recent call last):
  5.   File "setup.py", line 199, in ?
  6.     data_files=[("bin", ["zhfsj.glade", ])]
  7.   File "D:\Python24\lib\distutils\core.py", line 149, in setup
  8.     dist.run_commands()
  9.   File "D:\Python24\lib\distutils\dist.py", line 946, in run_commands
  10.     self.run_command(cmd)
  11.   File "D:\Python24\lib\distutils\dist.py", line 966, in run_command
  12.     cmd_obj.run()
  13.   File "setup.py", line 169, in run
  14.     py2exe.run(self)
  15.   File "D:\Python24\Lib\site-packages\py2exe\build_exe.py", line 197, in run
  16.     self._run()
  17.   File "D:\Python24\Lib\site-packages\py2exe\build_exe.py", line 248, in _run
  18.     self.find_needed_modules(mf, required_files, required_modules)
  19.   File "D:\Python24\Lib\site-packages\py2exe\build_exe.py", line 1144, in find_
  20. eeded_modules
  21.     mf.import_hook(mod)
  22.   File "D:\Python24\Lib\site-packages\py2exe\mf.py", line 103, in import_hook
  23.     return Base.import_hook(self,name,caller,fromlist)
  24.   File "D:\Python24\lib\modulefinder.py", line 124, in import_hook
  25.     q, tail = self.find_head_package(parent, name)
  26.   File "D:\Python24\lib\modulefinder.py", line 178, in find_head_package
  27.     raise ImportError, "No module named " + qname
  28. ImportError: No module named pangocairo
  29. D:\zhfsj>
复制代码

论坛徽章:
0
20 [报告]
发表于 2006-02-15 09:30 |只看该作者
ImportError: No module named pangocairo
你有安装pycairo模块吗?
http://www.mapr.ucl.ac.be/~gusti ... 2-1.win32-py2.4.exe
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP