0%

Package Python program into app in MAC

1.Install package “py2app”.
1
pip install py2app
2.Package the python’s program into ‘setup.py’
1
py2applet --make-setup xxx.py
3.Encapsulate the ’setup.py‘ into an app
1
2
3
4
python setup.py py2app -A
# For other computers without SDK, including lib library.
python setup.py py2app
# For computers without SDK, you need to remove - A and package all dependencies
ps:
1
2
3
When an error is reported, you need to open setup Py file to change 
the relevant configuration.
The template is as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""
This is a setup.py script generated by py2applet

Usage:
python setup.py py2app
"""

from setuptools import setup

APP = ['Htu_login.py']
DATA_FILES = []
OPTIONS = {'includes':['requests','lxml','re','sys','time']}# package

setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)