I am trying to convert a .py file to .exe file using cx-freeze. I have installed cx-freeze and have added python to my computer path. However, Using the code below, i am supposed to locate the qwindows.dll file in python33. I can't seem to find the file, not only that, i cant seem to find the platforms folder. I have tried uninstalling pyqt4 and reinstalling it using an installer and also installing pyqt5. I still cant find the folder/file...Nothing works??!!!
The code i used is here:
import sys
from cx_Freeze import setup, Executable
base = "Win64GUI"
path_platforms = ( "C:\Python33\Lib\site-packages\PyQt4\plugins\platforms\qwindows.dll", "platforms\qwindows.dll" )###Find directory of qwindows.dll###
build_options = {"includes" : [ "re", "atexit" ], "include_files" : [ path_platforms ]}
setup(
name = "Starters 'R' Us", ###Janu change your name here###
version = "0.1",
description = "Maths Assessment System",
options = {"build_exe" : build_options},
executables = [Executable("MyProgram.py", base = base,shortcutName="Starters 'R' Us",shortcutDir="DesktopFolder")]###Change the .py file to yours.###
)
###the shortcut creates shortcut on your desktop###
Related
So... simple question: I'm trying to use cx_Freeze to build an .exe file.
In my script I import some packages, functions from another .py file and also an array from a .csv file.
How do I compile this into one .exe file / a directory containing an .exe file?
I've noticed that there is a "options" parameter, which I tried filling with
"packages": ["numpy","pandas","userinput","Atoms.csv"]
But no luck. The .exe file just opens and closes again
EDIT
So I've changed the setup.py to
from cx_Freeze import setup,Executable
includefiles = ['Atoms.csv','userinput.py']
includes = []
excludes = []
packages = ['numpy','pandas']
setup(
name = 'Molar mass',
version = '1.0',
description = 'A calculator for the molar mass',
author = '',
options = {'build_exe': {'includes':includes,'excludes':excludes,'packages':packages,'include_files':includefiles}},
executables = [Executable('Molarmass.py')]
)
Which gives me the error "ImportError: No module named 'numpy'"
And if I try to run it without the packages, I can't open the .exe file.
I'm using cx_freeze to export a Python program. The exported program was working fine until I tried to add shortcut with icon on the desktop. I've taken the codes from there and there.
When running the main.exe file from its folder in C://Program files, there is no problem, but when I run the shortcut on the desktop there is this error :
The setup.py file :
import sys
from cx_Freeze import setup,Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
includefiles = ['bouton_ajouter_contact.png','bouton_contacts.png','bouton_deconnexion.png',\
'bouton_message.png','bouton_messages.png','bouton_reglages.png','fond_home.png','worldco.png']
includes = []
excludes = []
packages = ['os']
setup(
...
options = {'build_exe': {'includes':includes,'excludes':excludes,'packages':packages,'include_files':includefiles}},
executables = [Executable(
'main.py', base=base,
shortcutName="Messagerie Cryptee", shortcutDir="DesktopFolder",
icon='messagerie_cryptee_ico.ico'
)]
)
All the .png files and the .ico file are in the same folder as the setup.py file, in Python34. Before adding a shortcut, this problem was not there, and I don't remember having changed anything about images.
Thanks for help
I am writing an installation program for a larger program I am writing, and I am using CxFreeze to convert it to an executable file, however, when I run the .exe file, it crashes with the line "import pip", and brings up (as shown below), so basically my question is: Is it possible to use CxFreeze on an application with pip imported?
Edit:
Here are all the files I am using:
setup.py (V1):
from cx_Freeze import *
import os, pip
setup(name=("ARTIST"),
version = "1",
description = "ARTIST installation file",
executables = [Executable("Install ARTIST.py"), Executable("C:\\Python34\\Lib\\site-packages\pip\\__init__.py")],
)
This brings up the error:
setup.py (V2):
from cx_Freeze import *
import os, pip
setup(name=("ARTIST"),
version = "1",
description = "ARTIST installation file",
executables = [Executable("Install ARTIST.py"],
options = {"build_exe": {"packages":[pip]}}
)
This brings up an error in the setup.bat file:
Edit:
If anyone wants to look at the website where I am publishing the larger program, here is the link:
alaricwhitehead.wix.com/artist
Edit2:
this is the error i get when i use py2exe:
Edit3:
here is a copy of the code:
https://www.dropbox.com/s/uu46iynm8fr8agu/Install%20ARTIST.txt?raw=1
please note: I didn't want to have to post a link to it, but it was too long to post directly.
The are two problems in your setup script. The first problem is that you specified extra modules to include in your frozen application under the packages option of the build_exe command: packages is for specifying which packages of your application you need to include, for the external modules (such as pip) you need to use includes. The second problem is that you need to pass to includes a list of strings of modules and not the module itself:
setup(
name=("ARTIST"),
version="1",
description="ARTIST installation file",
options={
'build_exe': {
'excludes': [], # list of modules to exclude
'includes': ['pip'], # list of extra modules to include (from your virtualenv of system path),
'packages': [], # list of packages to include in the froze executable (from your application)
},
},
executables=[
Executable(
script='run.py', # path to the entry point of your application (i.e: run.py)
targetName='ARTIST.exe', # name of the executable
)
]
)
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 ?
I want to make a self-contained .exe file.
I have managed to use cx_Freeze to build one that works on my machine, but it is throwing an error about needing the .dlls when I sent it to someone. I read a few of the similar questions, which is how I ended up including packages in the build options.
I suspect that once I get past this particular problem, I will end up needing to include other stuff in the .exe....any help getting around that pitfall is appreciated! The end user needs to be able to only use the .exe and not have to install other files.
Here is my current setup.py:
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == 'win32':
base = 'Win32GUI'
build_options = {"includes" : [ "re", "atexit"], "packages": ["PyQt4.QtCore", "PyQt4.QtGui"]}
setup( name = "Hex Script Combination",
version = "0.1",
description = "Contact (info) with questions",
options = {"build_exe" : build_options},
executables = [Executable("Project.py", base=base)])
ETA:
I tried IExpress, and I'm running into this error:
(Picture uploaded but for some reason, neither picture in this post is showing)
File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in <module>
code = importer.get_code(moduleName)
ZipImportError: can't find module 'projec~1__main__'
I did NOT find a way to do exactly what I wanted. I did, however, discover that I was getting an installer I wasn't aware of for distribution that did install everything that was in my exe directory.
File path was ~\dist, and it contained only an .msi file. Launching it installed everything that was in ~\build\exe.win32-2.7