Python从入门到放弃 (二) 将.py文件转化为win 10下的可执行程序

一.Pyinstaller库的简介

该第三方库的作用就是把用python语言编写的程序转化为在windows环境下可执行程序.exe文件

官方地址见下面:

Features — PyInstaller bundles Python applicationshttp://www.pyinstaller.org/features.html

二.Pyinstaller库的安装

在[cmd]界面中输入 pip3 install Pyinstaller 即可安装此库如下图所示,笔者已经安装好了。

三.Pyinstaller库的使用

1.指令原型

pyinstaller [options] script [script …] | specfile

说明:

  • Writes myscript.spec in the same folder as the script.

  • Creates a folder build in the same folder as the script if it does not exist.

  • Writes some log files and working files in the build folder.

  • Creates a folder dist in the same folder as the script if it does not exist.

  • Writes the myscript executable folder in the dist folder

下列举例说明两种转化你的.py文件的用法。假设你在D盘建立了Hello.py这个程序

那么该文件地址为 D:\Hello.py  按照下面的例子来写,其中options要看具体的说明

pyinstaller options… ~/myproject/source/myscript.py

pyinstaller options… ~D:\Hello.py

另一种用法

pyinstaller "C:\Documents and Settings\project\myscript.spec"

pyinstaller "D:\Hello.py"这个简单直接。笔者写了一个简单的输入姓名的程序name.py,转化后就是文件类型为 Compiled Python File,可以直接在windows上运行。

2.OPTIONS 指令下选项说明见我的下一篇文章

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值