首页 > 学技术 > 技术网文 > Python > 正文

[保留] py2exe-明明有user32.dll,为什么还要报错?


来源 chinaunix.net 酷勤网整理

*** copy extensions ***
copying C:\Python24\DLLs\bz2.pyd ->; C:\Python24\mywork\clock\dist
copying C:\Python24\DLLs\unicodedata.pyd ->; C:\Python24\mywork\clock\dist
copying C:\Python24\DLLs\zlib.pyd ->; C:\Python24\mywork\clock\dist
*** copy dlls ***
copying C:\Python24\w9xpopen.exe ->; C:\Python24\mywork\clock\dist
copying C:\WINDOWS\system32\python24.dll ->; C:\Python24\mywork\clock\dist
setting sys.winver for 'C:\Python24\mywork\clock\dist\python24.dll' to 'clock'
copying C:\WINDOWS\system32\MSVCR71.dll ->; C:\Python24\mywork\clock\dist

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

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

        ADVAPI32.dll - C:\WINDOWS\system32\ADVAPI32.dll
        USER32.dll - C:\WINDOWS\system32\USER32.dll
        SHELL32.dll - C:\WINDOWS\system32\SHELL32.dll
        KERNEL32.dll - C:\WINDOWS\system32\KERNEL32.dll

好像说的是这几个dll文件找不到。但我找过,有,而且路径也是对的。

python 2.4.1
py2exe 0.6
windows XP
C盘是NTFS的文件系统。小弟初学python,请教。



 wolfg 回复于:2005-09-08 15:03:39

exe文件生成了没有?


 墟里烟 回复于:2005-09-08 17:22:27

没有.
写了一个hello world,可以生成.但加上Tkinter之后就不行了.
好像只要加载模块就编译不成功。

dist目录里除了exe以外,别的都有。w9x*.exe也生成了。有python24.dll,libary.zip也生成了。*.pyc也有。


 xichen 回复于:2005-09-08 20:35:30

估计是缺乏Tkinter的py2exe环境.
用--help命令看一下好吗/
我这里的机器上没有装py2exe,没办法帮你.


 wolfg 回复于:2005-09-08 20:50:10

你的setup.py怎么写的,贴出来看看


 墟里烟 回复于:2005-09-08 22:28:07

#hls.py
from Tkinter import *
import colorsys

def update(*args):
r,g,b = colorsys.hls_to_rgb(h.get()/255.0,l.get()/255.0,s.get()/255.0)
r,g,b = r*255,g*255,b*255
rgb.configure(text='RGB:(%d,%d,%d)' % (r,g,b))
c.configure(bg='#%02X%02X%02X' % (r,g,b))

root = Tk()
hue = Label(root,text='Hue')
hue.grid(row=0,column=0)
light = Label(root,text="Light")
light.grid(row=0,column=1)
sat = Label(root,text='Saturation')
sat.grid(row=0,column=2)
rgb = Label(root,text='RGB:(0,0,0)')
rgb.grid(row=0,column=3)

h = Scale(root,from_=255,to_=0,command=update)
h.grid(row=1,column=0)
l = Scale(root,from_=255,to_=0,command=update)
l.grid(row=1,column=1)
s = Scale(root,from_=255,to_=0,command=update)
s.grid(row=1,column=2)

c = Canvas(root,width=100,height=100,bg='Black')
c.grid(row=1,column=3)

root.mainloop()

[书上抄的一道例题。]

# setup.py
from distutils.core import setup
import py2exe

setup(name="choosecolor",scripts=["hls.py"],) 

hls.py用pythonw.exe可以直接正常打开,但就是编译不了。
我机子上是装了Tkinter的。(好像2.4的都是装python的时候就自己动装上Tkinter了吧。)

P.S:这些例子都是从《Python v2.1宝典》上抄的。刚看了一点,书就不见了。郁闷ing,还要赔给图书馆啊!五倍的money啊!


 xichen 回复于:2005-09-09 09:14:35

第一,请以后贴代码的时候注意使用code标签来缩进

我的环境为Python 2.3+py2exe 0.5
hls.py代码如下

from Tkinter import * 
import colorsys 

def update(*args): 
    r,g,b = colorsys.hls_to_rgb(h.get()/255.0,l.get()/255.0,s.get()/255.0) 
    r,g,b = r*255,g*255,b*255 
    rgb.configure(text='RGB:(%d,%d,%d)' % (r,g,b)) 
    c.configure(bg='#%02X%02X%02X' % (r,g,b)) 

root = Tk() 
hue = Label(root,text='Hue') 
hue.grid(row=0,column=0) 
light = Label(root,text="Light") 
light.grid(row=0,column=1) 
sat = Label(root,text='Saturation') 
sat.grid(row=0,column=2) 
rgb = Label(root,text='RGB:(0,0,0)') 
rgb.grid(row=0,column=3) 

h = Scale(root,from_=255,to_=0,command=update) 
h.grid(row=1,column=0) 
l = Scale(root,from_=255,to_=0,command=update) 
l.grid(row=1,column=1) 
s = Scale(root,from_=255,to_=0,command=update) 
s.grid(row=1,column=2) 

c = Canvas(root,width=100,height=100,bg='Black') 
c.grid(row=1,column=3) 

root.mainloop() 

setup.py的代码如下,我改动了这个文件内容

from distutils.core import setup
import py2exe

setup(windows=["hls.py"],) 

编译过程如下

python setup.py py2exe
.............
...............
...........
*** copy dlls ***
copying C:\WINDOWS\system32\python23.dll ->; D:\tt\dist
copying c:\python23\DLLs\tcl84.dll ->; D:\tt\dist
copying C:\WINDOWS\system32\COMCTL32.dll ->; D:\tt\dist
copying c:\python23\w9xpopen.exe ->; D:\tt\dist
copying c:\python23\DLLs\tk84.dll ->; D:\tt\dist
copying c:\python23\lib\site-packages\py2exe\run_w.exe ->; D:\tt\dist\hls.exe

成功生成hls.exe


 wolfg 回复于:2005-09-09 09:24:58

引用:原帖由 "xichen"]成功生成hls.exe
 发表:

同意,方便别人试验你的代码

你的问题这样解决,把setup.py改成这样
# setup.py

from distutils.core import setup
import py2exe
     
setup(name="choosecolor",windows=["hls.py"],) 


注意这里  [color=red]windows=["hls.py"][/color]


 wolfg 回复于:2005-09-09 09:25:55

引用:原帖由 "xichen"]成功生成hls.exe
 发表:



还是老大你快啊,呵呵


 xichen 回复于:2005-09-09 09:31:33

呵呵。


 墟里烟 回复于:2005-09-09 13:08:01

拜^
多谢xichen!PS:你的名字和我的真名很像。

代码我贴的时候我知道要注意缩进,我以为像另一个论坛一样是把代码贴到代码区的。但又没找到。没注意到code标签。给大家添麻烦了。

你发的另两篇《转贴一个py2exe的使用方法,希望能给大家帮助。》和《新手如何开始Python的GUI界面(和Limodou的谈话记录) 》收下。多谢!!!




原文链接:http://bbs.chinaunix.net/viewthread.php?tid=608237
转载请注明作者名及原文出处



收藏本页到: