es.davy.ai

Preguntas y respuestas de programación confiables

¿Tienes una pregunta?

Si tienes alguna pregunta, puedes hacerla a continuación o ingresar lo que estás buscando.

Cómo convertir el archivo de Python a DMG en MAC.

Intenté convertir mi código de Python a un archivo dmg y utilicé el método py2app. Mi código puede ejecutarse correctamente a través de Visual Studio Code, pero después de utilizar el método py2app, no puedo abrir el archivo de aplicación. Aparece el mensaje “La aplicación ‘molarity_calculators’ no se puede abrir”.

from tkinter import*
import pyperclip 
import math

win = Tk() 
win.title("Concentration Calculators")
win.geometry("400x450+200+200")
win.config(bg="#323232")

title_text = Label(text="Concentration Calculators", fg="skyblue", bg="#323232")
title_text.config(font="微軟正黑體 20")
title_text.pack()

mw = Label(text="Molecular Weight:", fg="white", bg="#323232")
mw.pack()
mw_entry = Entry(justify='center') 
mw_entry.pack()

weight = Label(text="Mass of Solute (mg):", fg="white", bg="#323232")
weight.pack()
weight_entry = Entry(justify='center')
weight_entry.pack()

volumn = Label(text="Total Solution Volumn (ml):", fg="white", bg="#323232")
volumn.pack()
volumn_entry = Entry(justify='center')
volumn_entry.pack()

conc = Label(text="Concentration (mM):", fg="white", bg="#323232")
conc.pack()
conc_entry = Entry(justify='center')
conc_entry.pack()

molar_show = Label(text="", fg="white", bg="#323232")
molar_show.pack()

def gen_conc():
    ms1 = weight_entry.get()
    mw2 = mw_entry.get()
    vol = volumn_entry.get()
    conc = conc_entry.get()

    gen_conc = ((float(ms1) / float(mw2)) / float(vol)) * 1000

    molar_show.config(text=str(gen_conc) + " mM")

def copy():
    xy = molar_show.cget("text")
    pyperclip.copy(xy) 

generate_btn = Button(text="Concentration", command=gen_conc) 
generate_btn.pack()

copy_btn = Button(text="Copy Result", command=copy)
copy_btn.pack()

win.mainloop()

from setuptools import setup

APP = ['molarity_calculators.py']
OPTIONS = {'argv_emulation': True}

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

Answer

  1. Avatar for davy.ai

    Parece haber un problema al abrir el archivo de aplicación generado por el método py2app. Una posible solución es verificar si la aplicación está siendo firmada correctamente. A veces, el sistema operativo puede bloquear la apertura de la aplicación si no está firmada correctamente. Otra solución podría ser verificar si hay alguna dependencia faltante que el código requiere para funcionar, lo cual puede evitar que se abra. Sería útil revisar los registros en busca de mensajes de error o intentar ejecutar la aplicación desde la línea de comandos para ver si hay errores específicos que puedan solucionarse.

Comments are closed.