免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5733 | 回复: 6
打印 上一主题 下一主题

py2exe使用遇到的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-02-08 20:36 |只看该作者 |倒序浏览
我有个最简单的pygtk程序
想用py2exe包装一下
我用了下面的几个命令都不行
python setup.py py2exe
python setup.py py2exe -i gtk
python setup.py py2exe -p gtk
请问是不是缺少什么?


  1. #!/usr/bin/python
  2. #hello.py
  3. import gtk

  4. win=gtk.Window()
  5. win.show()
  6. gtk.main()


  7. #!/usr/bin/python
  8. # setup.py
  9. from distutils.core import setup
  10. import py2exe
  11. setup(console=["hello.py"])
复制代码


出现的错误是这样的

  1. *** copy extensions ***
  2. copying D:\Python24\lib\site-packages\gtk-2.0\gtk\glade.pyd -> D:\1\dist
  3. *** copy dlls ***
  4. copying D:\Program Files\Common Files\GTK\2.0\bin\libxml2.dll -> D:\1\dist
  5. copying D:\Program Files\Common Files\GTK\2.0\bin\libglade-2.0-0.dll -> D:\1\dis
  6. t
  7. copying D:\Python24\lib\site-packages\py2exe\run.exe -> D:\1\dist\hello.exe
  8. The following modules appear to be missing
  9. ['gdk', 'ltihooks']

  10. *** binary dependencies ***
  11. Your executable(s) also depend on these dlls which are not included,
  12. you may or may not need to distribute them.

  13. Make sure you have the license if you distribute any of them, and
  14. make sure you don't distribute files belonging to the operating system.

  15.    GDI32.dll - D:\WINNT\system32\GDI32.dll
  16.    KERNEL32.dll - D:\WINNT\system32\KERNEL32.dll
  17.    OLE32.dll - D:\WINNT\system32\OLE32.dll
  18.    IMM32.DLL - D:\WINNT\system32\IMM32.DLL
  19.    SHELL32.dll - D:\WINNT\system32\SHELL32.dll
  20.    WS2_32.DLL - D:\WINNT\system32\WS2_32.DLL
  21.    msvcrt.dll - D:\WINNT\system32\msvcrt.dll
  22.    ADVAPI32.dll - D:\WINNT\system32\ADVAPI32.dll
  23.    USER32.dll - D:\WINNT\system32\USER32.dll
复制代码

论坛徽章:
0
2 [报告]
发表于 2006-02-08 22:40 |只看该作者
  1. #!/usr/bin/python
  2. # setup.py
  3. from distutils.core import setup
  4. import py2exe
  5. setup(windows=["hello.py"])
复制代码


你的程序是GUI程序

论坛徽章:
0
3 [报告]
发表于 2006-02-09 01:56 |只看该作者
还是不行
还是说找不到模块

  1. The following modules appear to be missing
  2. ['gdk', 'ltihooks']
复制代码

论坛徽章:
0
4 [报告]
发表于 2006-02-09 17:16 |只看该作者

哈哈,今天折腾了一下PY2EXE,挺好用啊

楼主,你干什么把HELLO的程式和SETUP的程式放在一起啊,这需要两个文件啊..

用两个文件后,在DOS界面,路径选对,输入  setup.py  py2exe  就可以了..

不过这个py2exe不是有缺陷嘛,第三方软件的共同缺陷

论坛徽章:
0
5 [报告]
发表于 2006-02-09 18:13 |只看该作者
是两个文件
一个hello.py是我的程序
一个setup.py
只是把他们贴在了一起

如果只包含简单的print语句
那么打包就没问题
但是如果用到了gtk的图形模块
打包的时候就说找不到那两个模块了
sigh

论坛徽章:
0
6 [报告]
发表于 2006-02-09 20:39 |只看该作者
OK
问题已解决
在这个地方找到的答案
http://starship.python.net/crew/theller/moin.cgi/Py2exeAndPyGTK
就是setup.py没写好

论坛徽章:
0
7 [报告]
发表于 2006-02-09 21:12 |只看该作者
再补充一点
有时候用py2exe打包pygtk时pango包会出运行时错误
解决的办法是重新拷贝pango的那个DLL
我也是在google上找到的
大家可以看下面的原文

  1. I saw a very similar error message when using PyGtk & py2exe on
  2. windows...perhaps it is something similar.

  3. I was using py2exe to package up all the files needed to run my PyGtk
  4. program, including DLLs.  It was copying the Pango DLL from my Gtk
  5. installation but not some of the data files Pango needed (which were
  6. installed along with Gtk in C:\GTK).  

  7. When I ran my program, it found the copied DLL but wasn't able to find
  8. the data files.  I found two ways to fix the problem:

  9. 1) copy the data files from C:\GTK and put them next to the Pango DLL.
  10. In my case I had to copy C:\GTK\lib, C:\GTK\share, and one other
  11. directory from C:\GTK which slips my mind at the moment

  12. 2) delete the copied pango DLL.  My program then used the one installed
  13. in C:\GTK and was able to find the data files in C:\GTK

  14. So, could your program be finding a 2nd copy of the pango DLL somewhere?

  15. -Mark Ive
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP