记录使用pyinstaller打包项目,老是搞忘

1. 到你想要打包的文件夹路径下面输入cmd

2.使用pyinstaller打包项目,首先你要先安装过pyinstaller,pip install pyinstaller,然后在控制台输入打包命令 

 

-F 是只生成一个单个文件(只有一个 exe 文件)

-w 是运行程序时不弹出命令行窗口,只对windows有效

-i 是添加icon图片,后面跟着图标的名字,我这里是nw.ico,然后是你想要打包的文件名字

3.打包结果

这里在文件夹里面出现两个文件夹,一个dist一个build,在dist里面就可以找到单个exe文件

有关打包路径的问题:

我是想要在程序中读取某个文件夹里面的文件,使用了各种方法都不行,最后是这样解决的:

if getattr(sys, 'frozen', False):
    current_path = os.path.dirname(os.path.abspath(sys.executable))
elif __file__:
    current_path = os.path.dirname(os.path.abspath(__file__))
self.model_mobilenet_v3_large = os.path.join(current_path,"models", "mobilenet_v3_large_state_dict.pkl")
self.model_mobilenet_v3_small = os.path.join(current_path,"models", "mobilenet_v3_small_state_dict.pkl")
self.model_InceptionV3 = os.path.join(current_path,"models", "InceptionV3_state_dict.pkl")
self.model_ResNet152 = os.path.join(current_path,"models", "ResNet152_state_dict.pkl")

 以后可以这样解决

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值