I built a python app, and I'm using Ubuntu 16.04 and python 2.7. I'm trying to compile the python script as .EXE to work on windows but I cannot find a way to make it start. I'm also having Selenium and Tkinter in my script.
Here's what my python file looks like:
import ast
import random
import thread
import time
import tkMessageBox
from Tkinter import *
import os
from selenium import webdriver
from selenium.webdriver import ActionChains
global geckodriver
if os.name == 'nt':
geckodriver = "./geckodriver.exe"
else:
geckodriver = "./geckodriver"
I'm also using a PNG file as tkinter icon and displayed picture in Tkinter:
photo = PhotoImage(file="smallblack.png")
root.tk.call('wm', 'iconphoto', root._w, photo)
w = Label(root, image=photo)
w.photo = photo
w.pack(side=TOP, pady=15)
and also using two text files for the script to read later:
def countlinks():
lines = 0
for line in open("checklinks.txt"):
lines += 1
return lines
but I thought this can be added later next to the generated .exe.
Now, here is my setup.py used by cx_freeze:
#setup.py
from cx_Freeze import setup, Executable
setup(
name = "MainExe",
version = "1.0.0",
options = {"build_exe": {
'packages': ["ast","random","thread","time", "tkMessageBox", "Tkinter", "os", "selenium"],
'include_files': ['smallblack.png','geckodriver','geckodriver.exe'],
'include_msvcr': True,
}},
executables = [Executable("main.py)]
)
What am I doing wrong? When building the .exe with pyinstaller (pyinstaller main.py --onefile
), the .exe builds but it doesn't open in Windows (opens a console window for 1 second and closes it), and if I'm trying to run it in CMD it says the program is too big.
When trying to run cx_freeze (python setup.py build
) it creates a .exe that will only open a console and nothing else happens.
I've been googling this for the last 5 hours with no success.
What am I doing wrong?