Python (2): Package python into an executable file app,

Source: Internet
Author: User

Python (2): Package python into an executable file app,

The original connection is: http://blog.csdn.net/freewebsys/article/details/46683645 reprint please be sure to indicate the source!

1. Package the mac program into an app

One pyinstaller has been tested in two solutions. No package is successful.
Py2app can be packaged successfully.

2. Install py2app

First install a gui framework wxpython
Refer:
Http://wiki.wxpython.org/
Http://wiki.wxpython.org/Getting%20Started

Official py2app Website:
Https://pythonhosted.org/py2app/
Installation:

sudo easy_install -U py2app
3. Package the app

It's quite simple:
For example, a simple gui, hello. py

#!/usr/bin/env pythonimport wxapp = wx.App(False)  # Create a new app, don't redirect stdout/stderr to a window.frame = wx.Frame(None, wx.ID_ANY, "Hello World") # A Frame is a top-level window.frame.Show(True)     # Show the frame.app.MainLoop()

Generate the setup file:

Py2applet -- make-setup hello. py # package: python setup. py py2app-

Generate file:

Double-click a few to run.

4. Summary

The original connection is: http://blog.csdn.net/freewebsys/article/details/46683645 reprint please be sure to indicate the source!

Because the wxpython library is installed on the local machine, all tasks can be run directly. If you want to use it on A computer without the sdk installed, remove the-A parameter and package all dependencies.

# Self-developed, fast packaging. Python setup. py py2app-A # For other computers without sdks, including the lib library. Python setup. py py2app

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.