安装pyinstaller
pip --default-timeout=100 install pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple
- 尽量选择旧的版本,新的版本依赖比较多
- 使用pyinstaller打包程序
pyinstaller -F -i tt.ico tt.py
-i
给应用程序添加图标
-F
指定打包后只生成一个exe格式的文件
-D
–onedir
创建一个目录,包含exe文件,但会依赖很多文件(默认选项)
-c
–console
, –nowindowed
使用控制台,无界面(默认)
-w
–windowed
,–noconsole
使用窗口,无控制台
-p
添加搜索路径
安装PythonMagick
由于版本问题通过pip install PythonMagick -i https://pypi.tuna.tsinghua.edu.cn/simple
总是安不上,只能通过本地安装。
- PythonMagick下载:http://www.imagemagick.org/
import PythonMagick
img = PythonMagick.Image("tt.jpg")
img.sample('128x128')
img.write('tt.ico')