Search code examples
python-3.xmacospy2app

py2app application will gives error when program is run


I am using py2app to create a program that generates a test link. Even without importing any code, it for some reason does not allow me to open it and gives the following error:

link error

in system.log, I get the following:

Jul  1 18:31:16 samanthas-imac com.apple.xpc.launchd[1] (org.pythonmac.unspecified.generatetestlink.2576[62449]): Service exited with abnormal code: 255

This is my setup.py file:

"""
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from setuptools import setup

APP = ['generatetestlink.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True,
           'packages': ['pyperclip']}

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

and this is my code (with some parts omitted):

import pyperclip

def makelink():
    quitting = False
    while quitting==False:
        originallink = input("Enter the original link: ")
        dimy = input("Enter the height: ")
        endcodelist = originallink.split("/m/")
        while(len(endcodelist)<2):
            endcodelist = originallink.split("/m/")
            originallink = input("Invalid link. Enter the original link: ")
            

        while type(dimy)!=int:
            try:
                dimy=int(dimy)
            except:
                dimy = input("Invalid height. Enter the height as an integer: ")
                print('stop2')

        endcode = endcodelist[1]

        newlink = "https://"+endcode+"&width=800&height="+str(dimy)
        pyperclip.copy(newlink)
        print(newlink)
        end = input("Enter another link? (y or n): ")
        if end == "n":
            quitting=True


makelink()

Any ideas on a fix? I tried pyinstaller, but it did not work either. It said image was missing.


Solution

  • It seems to work when I use tkinter instead of just using input statements. I think it is a permissions issue with opening programs that need to run in the terminal. I guess if people have similar issues, try using a GUI instead of just asking for input in the program.