Folder structure:
├──readme.txt
├──settings.py # program Parameters
├──settings.pyc
├──setup.py # installation files
├──spider.ico #windows under the program icon, Mac for. Icon
└──spider_am.py #主程序
setup.py:
#!/usr/bin/env python#! _*_ coding:utf-8 _*_from distutils.core import setupimport py2exeimport syssys.argv.append (' Py2exe ') # Double-click to run Py2exe _options = { # "dll_excludes": ["MSVCP90.dll",], "Compressed": 1, "optimize": 2, "ASCII": 0, # " Bundle_files ": 1, #64位机器上这句不用写 }setup ( name = ' crawler ', Version = ' 1.0 ', console = [{' script ': ' Spider_ am.py ', ' icon_resources ': [(0, ' Spider.ico ')]}], # Script & icon zipfile = None, options = {' Py2exe ': py2exe_ Options} )
Command line:
Original command: Python setup.py py2exe because the lxml third-party library in the main program is packaged so: Eventually the package command becomes: Python setup.py py2exe-p Lxml,gzip succeeded
There are two more folders in the last folder:
The program is in the Dist folder.
Run the program with the Py2exe package script as a double-click under Windows