2

So I finally have an app working while in py2app alias mode. I can open the file and it works well. After I remove the build & dist files and run python setup.py py2app, the package receives an error. Why would it be doing this?

magnolia.py:

    from splinter import Browser
import webbrowser

with Browser() as browser:
    # Visit URL
    url = "http://magnolia.msstate.edu/k12/login.asp"
    browser.visit(url)
    browser.fill('username', 'magn0897')
    # Find and click the 'search' button
    button = browser.find_by_name('btnG')
    # Interact with elements
    browser.find_by_xpath('//html/body/div[3]/div[1]/div/section/form/input').click()
#Open browser in new tab to keep browser open
webbrowser.open_new_tab('http://magnolia.msstate.edu/k12/elementary.asp')

#source: https://splinter.readthedocs.io/en/latest/mouse-interaction.html


#Instructions:
# Activate: go into bin.... $source activate
# To Update Requirements File: $pip freeze > requirements.txt

#http://www.marinamele.com/from-a-python-script-to-a-portable-mac-application-with-py2app

setup.py:

from setuptools import setup

APP = ['magnolia.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True,'iconfile': 'robot.icns'}

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

After $open magnolia.app in terminal: enter image description here

1 Answers1

-1

You didn't give your os version so I will just give you the information that worked for me on MacOS X 10.10 Yosemite:

$pip3 virtualenv
$cd target/appsource/folder
$virtualenv env
$. env/bin/activate
$pip install py2app==0.11
$py2applet --make-setup appName.py

edit your settings to include any info you want

$python setup.py py2app -A

test everything to make sure your options are set up proper and everything is working as expected

$rm -rf build dist
$python setup.py py2app
$deactivate

If you are running Yosemite, you should be off to the races. If you are rocking something newer, there may be a better version of py2app for you to use.

Mr. Kelsey
  • 508
  • 1
  • 4
  • 14