top of page
Search

PY2APP:CREATE STANDALONE APPLICATION FOR MAC OS

  • Writer: Yogesh M
    Yogesh M
  • Jun 7, 2018
  • 2 min read

This blog helps everyone to create a standalone application for mac OS

ree

Welcome to this blog post.

At first you should know how to create a GUI using tkinter or pyqt.

Then you should have python3.5 and a created GUI(that is the python file you are going to bundle) in your mac.


LETS START BUILDING OUR MAC APPLICATION:

Open the terminal:

->First you should download virtualenv package

1) pip3 install virtualenv

->Now create the python development environment with python3.5 in it

2) mkdir environment

3) cd environment

4) virtualenv envir -p PYTHON_EXE, --python=python3.5

->Now we should activate the virtual environment

5) . envir/bin/activate

->Now we should download the py2app(version=0.13) package inside the environment

6) pip3 install py2app==0.13

->Now copy the GUI Python file to the envir directory(/Users/profilename/envir)

->Now we should create a setup python file

7) py2applet --make-setup filename

->Now make some alteration to the setup file(located in the envir directory)

your setup file should look like this

8) modify the setup.py like this

ree


->Now build the application

9) python setup.py py2app

->We can also build the application in Alias mode(that works only in your computer)

9) python setup.py py2app -A

->Now the application is built in dist folder

10)test the application in your computer(it will work fine in your computer)

11)test the application in other computer(it will show some import errors in other computer)

->you can solve those errors by importing the packages while building the appilication again

12) rm dist build #removes the dist and build directory

13) python setup.py py2app --packages=required packages

14) deactivate #deactivates the virtualenv ->Now the application is built in dist folder

->The easiest way to wrap your application up for distribution at this point is simply to right- click the application from Finder and choose “Create Archive” and distributing it.

->Creating a dmg from bundle

15) now open disk utility of mac

16) File->new image->blank image. In name give any name and in image format:read/write

17) Now open terminal and type cd /Volumes/nameofdmgcreated/

18) type in terminal ln -s /Applications Applications #gives alise to application so that whenever someone opens the dmg it says to copy the app to application folder.

19) Now copy the .app from dist folder to mounted dmg 20) Now in disk utility:Image->convert->selectthedmg->give a name for dmg->image format:read only->save

->Now you can pass the the dmg to anyone


You can clone my appilication repository in github if you have any doubts:

open terminal and type:git clone https://github.com/yogesh5466/NewsReview.git


which was created using py2app


 
 
 

Comments


SIGN UP AND STAY UPDATED!
  • Facebook Social Icon
  • Twitter Social Icon
  • Google+ Social Icon
  • YouTube Social  Icon
  • Pinterest Social Icon
  • Instagram Social Icon
bottom of page