Python pyinstaller(Python pyinstaller)

Python pyinstaller

 一、安装Pyinstaller1、安装 pywin32        下载安装文件:查找到跟自己适用的python版本及window系统版本匹配的pywin32,下载后安装 (http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip)         使用pip命令安装:pip install pywin322、安装 Pyinstaller        下载安装文件安装:官网 http://www.pyinstaller.org/        使用pip命令安装:pip install PyInstaller二、使用Pyinstaller1、使用下载安装的方式安装的Pyinstaller打包方式将需要打包的文件放在解压得到的Pyinstaller文件夹中,打开cmd窗口,把路径切换到当前路径打开命令提示行,输入以下内容(最后的是文件名):        python pyinstaller.py -F myfile.py2、使用pip方式安装的Pyinstaller打包方式打开cmd窗口,把路径切换到文件所在路径(文件随便放在哪里都行)打开命令提示行,输入以下内容(最后的是文件名):        pyinstaller -F myfile.py3、输入参数的含义    -F 表示生成单个可执行文件    -w 表示去掉控制台窗口,这在GUI界面时非常有用。不过如果是命令行程序的话那就把这个选项删除吧!    -p 表示你自己自定义需要加载的类路径,一般情况下用不到    -i 表示可执行文件的图标三、注意事项    文件中使用了第三方库的打包方式在打包之前务必找到第三方库的包,把包复制到到跟myfile.py同目录下,然后再使用以上2种方式打包,否则会打包失败或者即使打包成功,程序也会闪退。下面演示一下使用了第三方库的打包方式:        找到第三方库的包,如使用了requests,可以使用查找的方式,找到这个包在哪里,然后把它复制到myfile.py同目录下        把包文件复制到myfile.py目录下         给程序换图标的方法            输入命令中添加一个-i tubiao.ico(图标的相对路径)。如图:四、exe文件生成    如果程序打包过程没有报错,则会生成3个文件夹(有时候是2个),其中名为dist的文件夹中会有一个myfile.exe文件,运行一下,如果没有问题就打包成功,可以把这个exe文件单独拿出去用,其他的生成的文件夹可以删掉了。    REF http://www.cnblogs.com/gopythoner/p/6337543.html

————————

Python pyinstaller

I. install pyinstaller1. Install pywin32. Download the installation file: find the pywin32 that matches your applicable Python version and window system version, and install it after downloading( http://www.lfd.uci.edu/ ~Gohlke / pythonlibs / #pip) use the PIP command to install: PIP install pywin322, install pyuninstaller, download the installation file, install: Official Website http://www.pyinstaller.org/ Use the PIP command to install: PIP install pyinstaller 2. Use pyinstaller1. Use the pyinstaller packaging method installed by downloading and installing. Put the files to be packaged in the extracted pyinstaller folder, open the CMD window, switch the path to the current path, and open the command prompt line, Enter the following (the last is the file name): Python pyinstaller py -F myfile. Py2. Open the CMD window by using pyinstaller package installed in PIP mode, switch the path to the path where the file is located (wherever the file is placed), open the command prompt line, and enter the following content (the last is the file name): pyinstaller – F myfile PY3. Meaning of input parameters – f means generating a single executable file – W means removing the console window, which is very useful in GUI interface. However, if it is a command-line program, delete this option! – P indicates that you customize the class path to be loaded. Generally, you do not use – I to represent the icon of the executable file. III. precautions: the packaging method of the third-party library is used in the file. Before packaging, be sure to find the package of the third-party library and copy the package to myfile Py in the same directory, and then use the above two methods to package, otherwise the packaging will fail or the program will flash back even if the packaging is successful. Here is a demonstration of the packaging method using a third-party library: find the package of the third-party library. If requests is used, you can use the search method to find where the package is, and then copy it to myfile Py, copy the package file to myfile Py directory , method of changing icons for programs , add – I tubiao to the input command ICO (relative path of the icon). As shown in the figure: IV. EXE file generation} if there is no error in the program packaging process, three folders (sometimes two) will be generated, of which there will be a myfile in the folder named dist Exe file, run it. If there is no problem, it will be packaged successfully. You can take this EXE file out separately, and other generated folders can be deleted.     REF http://www.cnblogs.com/gopythoner/p/6337543.html