在windows中,使用py2exe将py脚本转换成exe文件时,在dist目录下会有zip,dll等其他文件。如果想要只生成一个可单独运行的exe文件,需要在setup.py文件中添加bundle_files:1和zipfile=None。
代码如下:
- setup.py
from distutils.core import setup
import py2exe
options={
"py2exe":{
"bundle_files":1}
}
setup(options=options,
zipfile=None,
console=['helloworld.py'])
- helloworld.py
#!/usr/bin/env python3