Python - Error de compilación

 
Vista:

Error de compilación

Publicado por Víctor (2 intervenciones) el 12/05/2021 23:22:49
No consigo compilar (pasar te .py>.exe) el siguiente código; cuando lo ejecuto, este digamos que arranca y se cae.
Cuando lo corro en el PyCharm funciona correctamente, pero cuando tengo el .exe es cuando ya me funciona incorrectamente ¿Alguien me puede ayudar?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import tkinter as tk
from configparser import ConfigParser
from pythonping import ping
import socket
import time
 
config = ConfigParser()
config.read('config.ini')
 
ip = str(config['DATABASE']['db_IP_address'])
Subnet_masks = str(config['DATABASE']['db_Subnet_mask'])
Default_gateway = str(config['DATABASE']['db_default_gateway'])
port = int(config['DATABASE']['db_port'])
 
window = tk.Tk()
window.title("My first APP")
window.geometry('260x400+500+200')
window.resizable('FALSE','FALSE')
window.minsize('260','400')
window.maxsize('260','400')
window.iconbitmap('ico.ico')
time.sleep(2)
label = tk.Label(text="Version 0.1", fg="black", height=0)
label.grid(row = 0, column = 0, sticky = 'W', pady=1, padx = 5)
 
Label_IP_address = tk.Label(window, text="IP_address:")
Label_Subnet_mask = tk.Label(window, text="Subnet_mask:")
Label_Default_gateway = tk.Label(window, text="Default_gateway:")
 
Label_IP_address.grid(row=1, column=0, sticky='W', pady=1, padx = 5)
Label_Subnet_mask.grid(row=2, column=0, sticky='W', pady=1, padx = 5)
Label_Default_gateway.grid(row=3, column=0, sticky='W', pady=1, padx = 5)
 
Entry_IP_address = tk.Entry(window, width = 18)
Entry_Subnet_masks = tk.Entry(window, width = 18)
Entry_Default_gateway = tk.Entry(window, width = 18)
 
Entry_IP_address.insert(0, ip)
Entry_Subnet_masks.insert(0, Subnet_masks)
Entry_Default_gateway.insert(0, Default_gateway)
 
Entry_IP_address.grid(row=1, column=1, pady=1, padx = 5)
Entry_Subnet_masks.grid(row=2, column=1, pady=1, padx = 5)
Entry_Default_gateway.grid(row=3, column=1, pady=1, padx = 5)
 
c1_checked = tk.IntVar()
c1 = tk.Checkbutton(window, text = "Remember", variable = c1_checked, onvalue = 1, offvalue = 0)
c1.grid(row = 4, column = 0, sticky = "W", columnspan = 2, padx = 5, pady = 5)
 
Label_Port = tk.Label(window, text="Port:")
Label_Port.grid(row=4, column=1, sticky='W', pady=1, padx = 5)
 
Entry_Port = tk.Entry(window, width = 10)
Entry_Port.insert(0, port)
Entry_Port.grid(row=4, column=1, pady=5, padx = 8, sticky = "E")
 
def Click_Button_Connect():
    ip = Entry_IP_address.get()
    Subnet_masks = Entry_Subnet_masks.get()
    Default_gateway = Entry_Default_gateway.get()
    port = Entry_Port.get()
    try:
        result = ping(ip, verbose=True)
        if result.packet_loss == 0:
            print(result.rtt_min_ms)
            print(result.rtt_max_ms)
            print(result.rtt_avg_ms)
            try:
                con_des_socket(1)
                print(ip, Subnet_masks, Default_gateway, port)
                Note("Connected      ", "green")
            except:
                Note("No connected!     ", "red")
        else:
            Note("No Ping response!", "red")
    except:
        Note("No Ping response!", "red")
    if (c1_checked.get() > 0):
        config.set('DATABASE', 'db_IP_address', ip)
        Entry_IP_address.delete(0, 100)
        Entry_IP_address.insert(0, config['DATABASE']['db_IP_address'])
        config.set('DATABASE', 'db_Subnet_mask', Subnet_masks)
        Entry_Subnet_masks.delete(0, 100)
        Entry_Subnet_masks.insert(0, config['DATABASE']['db_Subnet_mask'])
        config.set('DATABASE', 'db_default_gateway', Default_gateway)
        Entry_Default_gateway.delete(0, 100)
        Entry_Default_gateway.insert(0, config['DATABASE']['db_default_gateway'])
        config.set('DATABASE', 'db_port', port)
        Entry_Port.delete(0, 100)
        Entry_Port.insert(0, config['DATABASE']['db_port'])
        with open('config.ini', 'w') as configfile:
            config.write(configfile)
 
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 
def con_des_socket(con_des):
    if con_des == 1:
        s.connect((ip, port))
    else:
        s.close()
 
Button_Connect = tk.Button(window, text = "Connect", height = 1, width = 15, command = Click_Button_Connect)
Button_Connect.grid(row = 5, column = 0, columnspan = 1, rowspan = 2, padx = 5, pady = 5)
 
def Click_Button_Disconnect():
    con_des_socket(0)
    Note("Disconnected!       ", "red")
    Text_Received.delete("0.0","10000.10000")
    #window.destroy()
 
Button_Disconnect = tk.Button(window, text = "Disconnect", height = 1, width = 15, command = Click_Button_Disconnect)
Button_Disconnect.grid(row = 5, column = 1, columnspan = 1, rowspan = 2, padx = 5, pady = 5)
 
Entry_Send = tk.Entry(window, width = 39, justify=tk.RIGHT)
Entry_Send.grid(row=7, column=0, columnspan=2, pady=1, padx = 5)
Entry_Send.focus()
Entry_Send.bind('<Return>', lambda event: Click_Button_Connect())
 
def Click_Button_Send():
    #send_recived(Entry_Send.get())
    Text_Received.insert("0.0",Entry_Send.get() + "\n")
 
def send_recived(s_r):
#    comando = "PW,1,\r"  # comando para pasar a modo ejecución/run
#    s.sendall(bytes(comando, 'ascii'))
#    print(bytes(comando, 'ascii'))
#    data = s.recv(1024)
#    print(data)
    s.sendall(bytes(Entry_Send.get()+"\r", 'ascii'))
    print(bytes(Entry_Send.get()+"\r", 'ascii'))
    data = s.recv(1024)
    print(data)
    Text_Received.insert("0.0", data + "\n")
 
Button_Send = tk.Button(window, text = "Send", height = 1, width = 15, command = Click_Button_Send)
Button_Send.grid(row = 8, column = 1, columnspan = 1, rowspan = 2, padx = 5, pady = 5)
 
Label_Received = tk.Label(window, text="Received:")
Label_Received.grid(row=12, column=0, sticky='W', pady=1, padx = 5)
 
Text_Received = tk.Text(window,width = 30, height = 8)
Text_Received.grid(row=13, column=0, columnspan = 2, sticky='W', pady=1, padx = 5)
 
label_Version = tk.Label(text="Version 0.1", fg="black", height=0)
label_Version.grid(row = 20, column = 1, sticky = 'E', pady=1, padx = 5,)
 
def Note(text, fg):
    label_Note = tk.Label(text="Note: "+ text, fg=fg, height=0)
    label_Note.grid(row=20, column=0, columnspan = 2, sticky='W', pady=1, padx=5)
 
window.mainloop()
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 2.808
Oro
Ha mantenido su posición en Python (en relación al último mes)
Gráfica de Python

Error de compilación

Publicado por tincopasan (1082 intervenciones) el 13/05/2021 14:29:14
más que el código, ¿con qué biblioteca lo estás compilando?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Error de compilación

Publicado por Víctor (2 intervenciones) el 13/05/2021 19:45:10
Estoy compilandolo con auto py to exe
Aqui:
https://pypi.org/project/auto-py-to-exe/

Probé con otras apps y todo ok; el problema vino aquí. Sabes que podría ser?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar