Python Packaging Program Py2exe Combat

Source: Internet
Author: User

Recently learning Python, so I wrote a script in Python, parking management system (Hey, I used PHP to do a system in college, but also won the award)

But the program now has too much of a limitation to use the Python environment before it is more cumbersome to install

So I want to first package the release of the program, commonly used is py2exe packaging, so I intend to use it this time. All right, here we go.

Preparatory work:

Install Py2exe

Write setup.py code as follows:

#-*-coding:utf-8-*-from
distutils.core Import setup
import py2exe
# Powered by * *
INCLUDES = []
Options = {"Py2exe":  
    {"Compressed": 1,  
     "optimize": 2,  
     "Bundle_files": 2,  
     "includes": Includes,  
     "Dll_excludes": ["MSVCP90.dll", "Mswsock.dll", "Powrprof.dll", "W9xpopen.exe"]}}  
Setup (
    options = options, 
    Description = "Parking Management system",  
    Zipfile=none,
    console=[{"script": "park.py", "Icon_resources": [(1, " Logo.ico ")]}]
    

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/

Specific option and other options is what meaning can search for a lot of information on the Internet, I will not repeat the

Next, run the command:

Python setup.py Py2exe

When the compilation is complete, a dist directory is generated in the current directory with the Park.exe file, which is not successful at execution

The following error occurred:

Traceback (most recent):
  file "park.py", line 4, in <module>
  File "Zipextimporter.pyo", line, I n load_module
  file "Pyquery.pyo", line 9, in <module>
  file "Zipextimporter.pyo", line, in Load_module
  file "Cssselectpatch.pyo", line 6, in <module>
  file "Zipextimporter.pyo", line, in Load_module
  file "L Xml\cssselect.pyo ", line 8, in <module>
  file" Zipextimporter.pyo ", line, in Load_module
  file" Lxml.etree.pyx ", line, in Init lxml.etree (src/lxml/lxml.etree.c:156121)
Importerror:no module named _ ElementPath

Find a solution on the Internet, the problem is in the lxml library.

The path cannot be found correctly because it is a lxml third-party library, with an additional instruction to specify the path; Change the compilation command to

Python setup.py py2exe-p Lxml,gzip

There's also more gzip, for the same reason as lxml.

The final execution of the generated file is Park.exe and Python27.dll, just put the two files in a folder, and then you can run on any computer. Ha ha. With this tool, we can use Python to do some useful gadgets for ourselves and our friends ... By the way to recommend a Python learning site http://***

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.