将python程序打包成exe文件的方法

将python程序打包成exe文件的方法

  1. 将pip版本升级到>=10.0.0(可用pip -V 查看当前版本)
    然后执行如下代码设置清华源:
    pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

  2. 安装pyinstaller:
    pip install pyinstaller

  3. 打包命令:
    (1) 普通方法: pyinstaller -F script.py
    pyinstaller -F -w script.py (无视窗,程序后台运行)
    (2) 当引用requests或bs4的时候需用如下命令打包,否则会缺少库文件。
    pyinstaller -F --hidden-import queue script.py

猜你喜欢

转载自blog.csdn.net/yao108yao/article/details/109010743