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 :)
Related
I am trying to create MSI installer for Windows with cx_Freeze package. Anyway, when running command python setup.py bdist_msi I get an error that it is invalid. Is there any options I am missing or maybe I cannot use it on Linux (I am using Debian 11)?
import sys
from pathlib import Path
from cx_Freeze import setup, Executable
company_name = '...'
product_version = '...'
product_name = '...'
product_description = '...'
base = None
build_exe_options = {}
bdist_msi_options = {
'initial_target_dir': r'[ProgramFilesFolder]\%s\%s' % (company_name, product_name),
}
if sys.platform == 'win32':
base = 'Win32GUI'
setup(
name=product_name,
version=product_version,
description=product_description,
options={
'build_exe': build_exe_options,
'bdist_msi': bdist_msi_options
},
executables=[Executable(
'app.py',
base=base,
shortcut_name=product_name,
shortcut_dir='DesktopFolder',
icon=str(Path(__file__).parent / 'icon.jpg')
)],
)
According to this section of cx_Freeze documentation cross compilation is indeed not possible. At least in the usual way.
cx_Freeze works on Windows, Mac and Linux, but on each platform it
only makes an executable that runs on that platform. So if you want to
freeze your programs for Windows, freeze it on Windows; if you want to
run it on Macs, freeze it on a Mac.
At a pinch, you can try to make a Windows executable using Wine. Our
experience is that you need to copy some files in manually after
cx_Freeze has run to make the executable work. We don’t recommend this
option.
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
)
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?
I am having trouble getting cx-freeze to make my executable, which makes heavy use of tkinter. My setup file code is as follows:
import sys
from cx_Freeze import setup, Executable
build_exe_options = {"packages":["tkinter"]}
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(
name = "distthis",
version = "0.01",
description = "Report Generator",
options = {"build_exe": build_exe_options},
executables = [Executable("distthis.py", base=base)]
)
When I try to build this from the command line (in the same directory) I can open the program, but it won't open a filedialog. I think the problem may be with tkinter. Can anybody help?
Ok I found the answer here: Keep getting a 'filedialog' error after creating executable with cx_Freeze
Following the advice at the bottom of the page I changed the tkinter module imports to explicit ones and the problem was gone.
If anybody knows why this strange behaviour happens I would love to know!
I'm trying to create a binary on Linux (Manjaro Linux, x86_64, python 3.4).
My app is a GUI software, written with PyQt.
Here is my setup.py:
import sys
import os
from cx_Freeze import setup, Executable
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
my_data_files = ["./images/", "./journals/", "./config/"]
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"],
"excludes": [
"tkinter"
],
'includes': [
'sip',
'PyQt4.QtCore',
'PyQt4.QtGui',
'PyQt4.QtNetwork',
'PyQt4.QtSql',
'scipy.sparse.csgraph._validation',
'sklearn.utils.sparsetools._graph_validation',
'scipy.special._ufuncs_cxx'
],
'include_files': my_data_files
}
setup(name = "guifoo",
version = "0.1",
description = "My GUI application!",
options = {"build_exe": build_exe_options},
executables = [Executable("gui.py", base=base)])
For now, I'm just starting. The "includes" part in the options is what I used when I compiled my binary with py2exe (it worked, but I want a unique tool to compile for all the platforms).
When I start the compilation with
python setup.py build
everything seems to work fine, but when I try to start the binary, I have this exception:
NotADirectoryError: [Errno 20] Not a directory: '/home/djipey/Desktop/test/build/exe.linux-x86_64-3.4/library.zip/text_unidecode/data.bin'
So I assume I have a problem with the module text_unidecode, but I can't really identify what the problem is.
Could you give me a hand please ?
EDIT:
Ok, sorry for the lack of precision, I didn't copy/paste the whole error message:
File "/usr/lib/python3.4/site-packages/text_unidecode/__init__.py", line 6, in <module>
with open(_data_path, 'rb') as f:
NotADirectoryError: [Errno 20] Not a directory: '/home/djipey/Desktop/test/build/exe.linux-x86_64-3.4/library.zip/text_unidecode/data.bin'
I think the issue can come from text_unidecode, but I don't know why. I installed it without any problem on my computer.
https://github.com/kmike/text-unidecode/blob/master/src/text_unidecode/init.py
EDIT 2:
If I integrate the code of text-unidecode (it is basically a single function) in my own code, it works. I think I know why I have this issue. In text-unidecode, there is a file called "data.bin" which contains data used by the function of text-unidecode. It is a part of the library, but it is not added to library.zip when I use cx_freeze. So text-unidecode can't work.
Is there an elegant way to solve this with cx_freeze ? Like an option, to add data files to library.zip ?