python转成exe_将python程序转换成exe程序
將python程序轉(zhuǎn)換成exe.
一、 先安裝python
2、安裝下載包,一路next。
3、為計(jì)算機(jī)添加安裝目錄搭到環(huán)境變量,如圖把python的安裝目錄添加到pth系統(tǒng)變量中即
可。(D:\\python32 是python的安裝路徑)
4、測(cè)試python安裝是否成功,cmd打開命令行輸入 python 命令,如下圖即成功了
6、直接解壓安裝到python的安裝目錄即可,C:\Python27\pyinstaller (pyinstaller 就是解壓后的目錄
7、進(jìn)入到安裝pyinstaller的目錄,新建一個(gè)存放py文件的目錄,在新建的目錄里放置我們的py程序
8、C:\Python27\PyInstaller-3.1.1
9、 轉(zhuǎn)換成exe.
在命令行執(zhí)行:python Makespec.py --console --onefile net\deploy_web.py
也許你會(huì)出現(xiàn)以下錯(cuò)誤,也許不會(huì),不報(bào)錯(cuò)直接第9步
報(bào)錯(cuò):Configfile is missing or unreadable. Please run Configure.py before building
10、解決方法:
在命令行執(zhí)行:Configure.py
報(bào)錯(cuò):Python 2.6+ on Windows support needs pywin32,Please install http://sourceforge.net/projects/pywin32/
如果Python版本太低,則安裝最新版本的 pywin32-217.win32-py2.7.exe,下載地址:http://sourceforge.net/projects/pywin32/files/pywin32/Build%20217/
無錯(cuò)誤時(shí)候,繼續(xù)執(zhí)行上 第9步
關(guān)于-F 參數(shù)解釋:
-F, --onefile
create a single file deployment
-D, --onedir
create a single directory deployment (default)
-o DIR, --out=DIR
create the spec file in directory. If not specified, and the current directory is Installer’s root directory, an output subdirectory will be created. Otherwise the current directory is used.
-n NAME, --name=NAME
optional name to assign to the project (from which the spec file name is generated). If omitted, the basename of the (first) script is used.
11、成功后生成一個(gè)和py腳本同名的目錄(deploy_web),在dict目錄下就生成一個(gè).exe 程序。
12、執(zhí)行完.exe程序后生成一個(gè)txt文件,里面就是想要的信息、
總結(jié)
以上是生活随笔為你收集整理的python转成exe_将python程序转换成exe程序的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 学python需要记得的单词_学习Pyt
- 下一篇: python怎么引用已经输入的信息_如何