Convert a python3 script in an executable with cx_Freeze - python

I'm recently made this chat app in python3 and I would like to convert my script in an executable, I made some research and I found and chose cx_Freeze because is multi-platform and I'm currently working with windows 10. I made this script to make the conversion but when I run it nothing happens. If someone could help me out here it will be great thanks!!!
import cx_Freeze
import sys
base = None
if sys.platform == 'win32':
base = "Win32GUI"
executables = [cx_Freeze.Executable("/mis programas/chat/aplicacion1.1.py", base=base, icon="/mis programas/iconos/3.png")]
cx_Freeze.setup(
name = "PyChaT",
options = {"build_exe": {"packages":["tkinter"], "include_files":["/mis programas/iconos/3.png"]}},
version = "1",
description = "Source of communication",
executables = executables
)

Related

error in creating executable file from python

i coded a python script in pycharm as "probe.py" and later built the executable(.exe) file out of it using the mentioned code in setup.py file but the exe file thus created shows error on opening as
import error mising required dependency['numpy'] even when it is present in my project.
error image
import sys
from cx_Freeze import setup,Executable
include_files = ['autorun.inf']
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(name="Probe",version="0.1",description="fun",
options={'build_exe':{'include_files': include_files}},
executables=[Executable("probe.py",base=base)])
`
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
build_exe_options = {"packages": ["numpy"],
include_files = ['autorun.inf']}
setup(
name = "Probe",
version = "0.1",
description = "fun",
options = {"build_exe": build_exe_options},
executables = [Executable("probe.py",base=base)]
)
run this script tell me if there is a problem
According to cx_Freeze documentation, try adding build_exe with a packages key.

Using cx_Freeze to create executable (cannot import _tkinter, DLL load failed)

I am trying to create an executable from my Python project using cx_Freeze, but keep running into this error:
Here's my setup.py:
import cx_Freeze
import os, sys
os.environ['TCL_LIBRARY'] = "D:\\Code\\Python\\3.5.2\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "D:\\Code\\Python\\3.5.2\\tcl\\tk8.6"
base = None
if sys.platform == "win32":
base = "Win32GUI"
executables = [cx_Freeze.Executable("Main.pyw", base=base)]
includes = ["tkinter"]
include_files = [r"D:\Code\Python\3.5.2\tcl\DLLs\tcl86t.dll", \
r"D:\Code\Python\3.5.2\tcl\DLLs\tk86t.dll"]
cx_Freeze.setup(
name="Test",
version = "1.0",
options={"Test.exe": {"packages":["pygame", "numpy"], "includes": includes, "include_files": include_files}},
executables = executables)
I tried putting tkinter in the "packages" list, but still get the same error. I also checked other StackOverflow posts and used parts of their setup.py code into mine, but nothing is working. I can't use PyInstaller as it doesn't support pygame and py2exe doesn't support Python 3.5. Any help would be appreciated.
Copy and Paste the files (tcl86t.dll, tk86t.dll) to the exe.win .
It worked for me.

import tkinter error

I have a .py file that I am trying to convert into an exe. I have tried numerous tries to build this file using cx_Freeze, but I keep getting the same error every time.
I've heard that it's got something to do with cx_Freeze, so I uninstalled cx_Freeze and reinstalled it using pip install cx_freezexxxx.whl wheel, but that still didn't work. I build my exe by writing python setup.py build in command line. Here's my setup .py code.
import cx_Freeze
import sys
import os
os.environ['TCL_LIBRARY'] = "C:\\Users\\louisa\\tcl\\tcl8.6"
os.environ['TK_LIBRARY'] = "C:\\Users\\louisa\\tcl\\tk8.6"
base = None
if sys.platform == 'win32':
base = "Win32GUI"
executables = [cx_Freeze.Executable("filemakergui.py", base=base, icon="Treetog-I-Documents.ico")]
cx_Freeze.setup(
name = "ALT File Maker",
options = {"build_exe": {"packages":["tkinter"], "include_files":["Treetog-I-Documents.ico", "Hopstarter-Sleek-Xp-Basic-Help.ico", "Custom-Icon-Design-Flatastic-2-Success.ico"]}},
version = "0.01",
description = "ALT File Maker",
executables = executables
)
Is there anything wrong with what I've written in my setup.py file? I've been stuck on this problem for several days now. Any tips on resolving an issue like this?

Python script has been built to exe, but how to make it not show the command prompt?

I have converted the python script into the exe version. But every time i executed it, it will show the command prompt. Is it possible to change the script to make it not show the command prompt?
Thanks in advance.
Change your .py file extension to .pyw
And then add Win32GUI to your script.
from cx_Freeze import setup, Executable
import sys
if sys.platform == "win32":
base = "Win32GUI"
setup(
name = u"XXX",
version = "1.0",
description = u"XXX",
options = {'build_exe': {'include_files':includefiles}},
executables = [Executable("XXXX.pyw" ,base = base)])

Why my freezed app is detected as possible virus?

I have packed my python application using the cx_freeze tool, this is my setup.py script:
import sys, os,imp
from cx_Freeze import setup, Executable
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"],"include_files":["ui\images","imageformats","qt.conf","icon.ico"] }
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup( name = "MonPy-Qt",
version = "1.5",
description = "Conversor de Divisas",
options = {"build_exe": build_exe_options},
executables = [Executable("main.py", base=base,icon="icon.ico")],
icon="icon.ico")
But when I try to run the generated .exe, avast detects as possible virus:
Someone have any idea to avoid this? thanks :)
Edit:
Translated message:
You are opening an application that may be potentially insecure. We
recomend open this application on the virtual environment Sandbox in
order to avoid any risk to the computer.
No Solution:
A recent update on Avast Antivirus specifies the reason to alert saying "Reputation: low".
Thanks to all :)

Categories

Resources