【问题标题】:py2app application will gives error when program is runpy2app 应用程序在程序运行时会报错
【发布时间】:2020-10-22 11:01:22
【问题描述】:

我正在使用 py2app 创建一个生成测试链接的程序。即使没有导入任何代码,由于某种原因它不允许我打开它并给出以下错误:

在 system.log 中,我得到以下信息:

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

这是我的 setup.py 文件:

"""
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'],
)

这是我的代码(省略了一些部分):

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()

关于修复的任何想法? 我尝试了 pyinstaller,但它也不起作用。它说图像丢失。

【问题讨论】:

  • 请注意,我还尝试使用 sudo 运行 setup.py,因为我认为这可能是权限问题。

标签: python-3.x macos py2app


【解决方案1】:

当我使用 tkinter 而不是仅使用输入语句时,它似乎可以工作。我认为这是打开需要在终端中运行的程序的权限问题。我想如果人们有类似的问题,请尝试使用 GUI 而不是仅仅在程序中要求输入。

【讨论】:

    猜你喜欢
    • 2018-10-09
    • 1970-01-01
    • 2013-09-01
    • 2023-02-19
    • 2019-05-10
    • 1970-01-01
    • 2013-05-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多