免费注册 查看新帖 |

Chinaunix

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

生成exe问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-08-15 10:04 |只看该作者 |倒序浏览
Python版本 2.5.2
py2exe版本py2exe-0.6.8.win32-py2.5.exe

脚本delfile.py
from datetime import timedelta,date
import string
import os
d=(date.today()-timedelta(1)).isoformat()
t=string.atol(d.replace('-','') + "000000")
channellist=os.listdir('d:/movie')
for channeldir in channellist:
    channeldir_path=os.path.join('d:/movie/',channeldir)
        os.chdir(channeldir_path)
        filelist=os.listdir(channeldir_path)
        for filename in filelist:
        f=string.atol(filename[0:14])
                if t > f:
                        f_path=channeldir_path + "/" + filename
                        os.remove(f_path)


脚本setup.py
# setup.py

from distutils.core import setup
import py2exe
setup(name="delfile",scripts=["delfile.py"])


运行 C:\python25\python setup.py py2exe
running py2exe
running build_scripts
*** searching for required modules ***
*** parsing results ***
creating python loader for extension 'unicodedata' (C:\Python25\DLLs\unicodedata.pyd -> unicodedata.pyd)
creating python loader for extension 'bz2' (C:\Python25\DLLs\bz2.pyd -> bz2.pyd)
*** finding dlls needed ***
*** create binaries ***
*** byte compile python files ***
byte-compiling C:\Python25\build\bdist.win32\winexe\temp\bz2.py to bz2.pyc
byte-compiling C:\Python25\build\bdist.win32\winexe\temp\unicodedata.py to unicodedata.pyc
skipping byte-compilation of C:\Python25\lib\StringIO.py to StringIO.pyc
skipping byte-compilation of C:\Python25\lib\UserDict.py to UserDict.pyc
skipping byte-compilation of C:\Python25\lib\atexit.py to atexit.pyc
skipping byte-compilation of C:\Python25\lib\base64.py to base64.pyc
.......
.......
.......
skipping byte-compilation of C:\Python25\lib\struct.py to struct.pyc
skipping byte-compilation of C:\Python25\lib\traceback.py to traceback.pyc
skipping byte-compilation of C:\Python25\lib\types.py to types.pyc
skipping byte-compilation of C:\Python25\lib\warnings.py to warnings.pyc
*** copy extensions ***
*** copy dlls ***

*** 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

有生成build和dist两个目录,但dist目录下只有bz2.pyd,library.zip,MSVCR71.dll,python25.dll unicodedata.pyd,w9xpopen.exe这几个文件,没有相应的exe文件生成,请问是什么回事?

论坛徽章:
0
2 [报告]
发表于 2008-08-15 10:25 |只看该作者
*** 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

论坛徽章:
0
3 [报告]
发表于 2008-08-15 10:30 |只看该作者

回复 #2 9119111 的帖子

这是表示什么意思,这几个文件在C:\WINDOWS\system32下都存在啊

论坛徽章:
0
4 [报告]
发表于 2008-08-15 10:33 |只看该作者
“make sure you don't distribute files belonging to the operating system ”是“确保你没有发布属于操作系统的文件”?
那样怎么做才没有发布

论坛徽章:
0
5 [报告]
发表于 2008-08-15 10:39 |只看该作者

回复 #1 yingsuifeng 的帖子

不清楚。没试过转EXE
网上看了下。好像也有这句话。
会不会你程序有问题

论坛徽章:
0
6 [报告]
发表于 2008-08-15 10:45 |只看该作者
from distutils.core import setup
import py2exe
setup(
    name = "delfile",
    console = ["delfile.py"],
    )

试着把安装脚本改成这样。

论坛徽章:
0
7 [报告]
发表于 2008-08-15 11:12 |只看该作者

回复 #6 jjj137 的帖子

改了还是一样
但奇怪的是我在Script.NET里运行delfile.py时用这个提示
  File "C:/Python25/delfile.py", line 9
    os.chdir(channeldir_path)
    ^
IndentationError: unexpected indent

但是在IDLE里运行却没有任何错误提示
这是什么会事?

论坛徽章:
0
8 [报告]
发表于 2008-08-15 11:45 |只看该作者
奇怪,应该生成一个delfile.exe才对……
错误提示是因为你缩进错了,第九行开始不应该缩进。
产生不了exe文件也可能是这个问题?不确定。

论坛徽章:
6
CU大牛徽章
日期:2013-04-17 10:59:39CU大牛徽章
日期:2013-04-17 11:01:45CU大牛徽章
日期:2013-04-17 11:02:15CU大牛徽章
日期:2013-04-17 11:02:36CU大牛徽章
日期:2013-04-17 11:02:582015年辞旧岁徽章
日期:2015-03-03 16:54:15
9 [报告]
发表于 2008-08-15 17:30 |只看该作者
原来python还能转exe..

论坛徽章:
0
10 [报告]
发表于 2008-08-15 17:37 |只看该作者
当然能了,不过要有python的dll来解析。

py2exe
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP