Execution error in cx_Freeze

Asked

Viewed 110 times

0

I am trying to make an executable of a script that I did where the program performs, in summary, the following tasks:

1 - Receives input from the operator 2 - Create some folders based on the inputated data 3 - Open Google Chrome and access a website and download some files 4 - Open one of these downloaded files and make changes 5 - Move these files from the Downloads folder to the created folders

So far, ok. The script works. However, when I make the script as an executable it only works until the folder creation part. My setup to build the executable is as follows:

from cx_Freeze import setup, Executable
import sys
import os

os.environ['TCL_LIBRARY'] = 'C:\\Users\\peo_cpena\\AppData\\Local\\Programs\\Python\\Python38\\tcl\\tcl8.6'
os.environ['TK_LIBRARY'] = 'C:\\Users\\peo_cpena\\AppData\\Local\\Programs\\Python\\Python38\\tcl\\tk8.6'

base = None
if sys.platform == 'win32':
    base = 'console'

executables = [Executable('MoneyOut_ComExcel_teste.py', base=base)]

packages = [
    'os',
    'datetime',
    'calendar',
    'time',
    'selenium',
    'shutil',
    'pandas',
    'idna'
]

options = {
    'build_exe':{
        'excludes': ['mpl_toolkits'],
        'packages': packages,
        'include_files':[
            os.path.join('C:\\Users\\peo_cpena\\AppData\\Local\\Programs\\Python\\Python38\\DLLs\\tcl86t.dll'),
            os.path.join('C:\\Users\\peo_cpena\\AppData\\Local\\Programs\\Python\\Python38\\DLLs\\tk86t.dll')
        ]
    },
}

setup(name='MoneyOutExec',
      options=options,
      version='1.0',
      description='Executavel do fechamento mensal',
      executables=executables
      )

And the imports I made in the original script were:

from os import mkdir
from datetime import date
from calendar import month_name
import time
from selenium import webdriver
from shutil import move
import pandas as pd

When I inputo the information in the executable console appears a sequence of messages very fast and then the console closes and I can not read what is written. Can anyone tell me how I could fix this problem?

1 answer

0

Come on. I’ve had the same problem as you.

The best thing is you open the file through the terminal. Voce navigates to its folder using the "cd" command and type dps:

start nomeDoApp.exe

For this to be happening you may also have compiled the wrong code. Something that happened to me as well. what solved this problem there for me was to put the Imports on the setup.py page as well. As follows:

from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from datetime import datetime
from selenium import webdriver
import pandas as pd
import urllib
import time

import tkinter as tk
from datetime import datetime
from tkinter import messagebox

setup file:

import sys
from datetime import datetime
from cx_Freeze import setup, Executable



import tkinter as tk
from datetime import datetime
from tkinter import messagebox
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium import webdriver
import pandas as pd
import urllib, time

base = None
if sys.platform == "win32":
    base = "Win32GUI"

executables = [
        Executable("whatsappv2.py", base=base)
]

buildOptions = dict(
        packages = [],
        includes = ['selenium','webdriver_manager', 'time', 'pandas', 'os','tkinter', 'datetime', 'urllib', ]
        
)

setup(
    name = "Whatsapp-BOT",
    version = "1.0",
    description = "este é um programa para automação de mensagens pelo whatsapp que envia arquivos tambem",
    options = dict(build_exe = buildOptions),
    executables = executables
 )

Browser other questions tagged

You are not signed in. Login or sign up in order to post.