I have spent the last 2 hours searching the web to find very little and nothing that helps.
Hoping someone here will be able to help me.
When using cx_Freeze to convert my .py file to a .exe files, I get an error stating no module named xlsxwriter can be found.
When this module is removed from the packages list the program compiles with no problem.
My code:
import cx_Freeze
Executables = [cx_Freeze.Executable("test.py")]
cx_Freeze.setup(
name="Sort PLL Bale Lists",
options={"build_exe": {"packages":['xlrd','xlsxwriter']}},
executables = Executables
)
Try adding includes list to your code eg: includes = [xlrd,xlsxwriter]. Refer to this SO post for help. If the error persists try installing xlrdwriter with pip install xlsxwriter.
There is a chance that you have xlrd already installed and you have not installed xlsxwriter. This can be verified with pip freeze. pip freeze will provide a list of installed packages.
Related
Problem: I get the error "ModuleNotFoundError: No module named 'pydicom'" when trying to run an executable created from a python program using cx_Freeze.
Background: I am using Python 3.8 with Anaconda 2020.02 on Windows 10 with PyCharm 2019.3.3 Community Edition as an editor, cx_Freeeze version 6.2, pydicom version 2.00. I am new to Python programming.
I had some initial trouble installing pydicom (pydicom-2.0.0-pyh9f0ad1d_0) and needed to go through the Anaconda Navigator to get it installed properly. Pydicom is not included with the standard package apparently.
Attempted: There are a lot of posts describing similar problems. I tried the following code for my setup.py but still no luck
from cx_Freeze import setup, Executable
packages = ['pydicom']
include_files = ["C:/<me>/.conda/pkgs/pydicom-2.0.0-pyh9f0ad1d_0/site-packages/pydicom"]
setup(name="MyProgram",
options={"build.exe": {'packages':packages, 'include_files':include_files}},
executables = [Executable("MyProgram.py")])
I fooled around with the include_files variable (e.g., ""C://.conda/pkgs/pydicom-2.0.0-pyh9f0ad1d_0/site-packages") with no luck.
I also use pandas in this code but there are no complaints when running (maybe it failed before executing any pandas code?)
Any suggestions welcome!
Thanks,
Tom
I am trying to convert a simple .py file into an .exe file in order to easily distribute it. I have looked up a few tutorials and realized that cx_Freeze seems to be the best route, however I have not found a solution for this error yet. If anybody can help please let me know.
The setup.py file I am using:
import sys
from cx_Freeze import setup, Executable
setup( name = "project",
version = "0.1",
description = "Makes life easier",
executables = [Executable("project.py")])
This file is in the same folder as the project.py file, and the 3.6 version of cx_Freeze is installed locally. However this error appears:
Thus far I have tried re-installing cx_Freeze, simply not using the python path, and that's about it as i'm not sure where to go next. If anyone has any ideas it would be greatly appreciated. If you need more info please tell me. I am on Python 3.6 if that helps.
That error suggests that your installation is flawed. Please use this command instead and retry afterwards.
python -m pip install cx_Freeze --upgrade
I have built a tkinter GUI for survey entry in python3.4 that uses a number of packages. I then need to compile it to an executable so that I can put it on a coworkers machine (we both are on windows7 platform) I've structured my setup.py to look like:
from cx_Freeze import setup, Executable
import sys
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(
name='Survey Entry',
version='3.5',
license='MIT',
description='GUI For entering survey data',
executables= [Executable("Survey Entry.py", base=base)],
options={"build_exe":{"packages":['tkinter','cx_Oracle','datetime','time','enter_survey','lookup',
'queryfuncs','login','gui', 'datetime', 'add_respondent', 'possible_matches']}}
)
This worked absolutely fine for tons of versions. But then I added a functionality that uses fuzzywuzzy to compare strings. When I include that and add fuzzywuzzy to the packages list in the options dictionary and compile it, I get a big error when I try to run the exe that ends with ImportError: No module named 'Levenshtein'
I don't understand because in my development the module works fine. I've tried to include Levenshtein in the setup but it doesn't exist as a module. I don't have python-Levenshtein installed though because I can't get the .whl to install on my windows machine.
Has anyone ran into this? Why would fuzzywuzzy cause this error when it runs fine through python? Is there something I'm missing?
The complete error can be seen here: http://imgur.com/a/rSKsS
EDIT: I was able to figure it out - I need the python-Levenshtein module installed, had to keep working at it to get the .whl to install (apparently I'm not as proficient with the command prompt as I wanted to believe). After that I included Levenshtein and fuzzywuzzy in the packages list and it compiled without error.
I'm going to leave this up because I couldn't find this on a google search so hopefully no one else falls victim!
Found the solution - python-Levenshtein needs to be installed. Got mine from gohlke's repository: http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-levenshtein - make sure you have the platform that matches your python installation! I run a x64 windows but I use x32 python for compatibility with my Oracle driver - so I needed to install the 32-bit module.
I'm incredibly new, and I was wondering if I could package colorama with cx_freeze, I've seen some people with a similar question yet I completely do not understand how to specifically choose colorama. Please, explain like I'm 10 years old. This is the coding in my setup.py file for cx_freeze:
from cx_Freeze import setup, Executable``
setup(name = "popcarventure" ,
version = "0.1" ,
description = "" ,
executables = [Executable("TheAdventure.py")])
Can you please post how to specifically import colorama? Much appreciated!
Note: I am using python 3.4 on windows, not python 2.
I recently started in python too and came across the same problem, aparently the latest version of cxfreeze has difficulties to include compressed modules (.egg, they are similar to .zip files).
So I'm going to try to explain in the easiest way I can, how I managed to get this working.
I assume you installed Python in C:\Python34.
Close any python command line or IDLE GUI.
Go to your Python34 installation folder, it should be on C:\Python34.
Once there open the "Lib" folder and locate "site-packages" folder
Now you need to delete your colorama egg file, this is the file that contains the module it is called colorama-0.3.3.egg or something similar, we need to install it uncompressed.
Create a .cfg file with the instruction to uncompress these egg files during the installation, go to C:\Python34\Lib\distutils create a new notepad file and name it: distutils.cfg and paste this:
[easy_install]zip_ok = 0
Save it and continue with the last step
Open a windows command prompt, write:
cd C:\python34\scripts
Now you simply write:
pip install colorama
Once it finishes you can start creating executables with colorama on it
NOTE: From now on any egg module you install with pip or easy_install or python install commands, will be uncompressed, so with cx_freeze they will work.
I just recently learned some python & pyqt basics, and today i wanted to convert a program I made to exe. I'm using python 3.4.1 and PyQt4 installed via binary installer (my system is 32-bit Windows 7 Enterprise, if it makes any difference). So I found Cx_Freeze should be a viable tool for the job, but as for now, I have spent several hours trying to make it work.
I installed Cx_Freeze from this site (after installing it from pypi.python.org and getting some error considering modules; this version supposedly has a patch that fixed it), and this is (the current version of) my setup.py file:
import sys
from cx_Freeze import setup, Executable
build_exe_options = {"packages": ["re", "sip"]}
setup(
name = "Project",
version = "1.0",
description = "desc",
options = {'build_exe': build_exe_options},
executables = [Executable("project.py", base = "Win32GUI")]
)
So, when i run it in cmd (python setup.py build), it creates the build folder and everything, but when i try to run the project.exe inside I get this error message.
Among other, I also had tried having "re" and "sip" in includes (instead of packages). Also one of earlier versions had no specific options defined by me. Also tried simply copying several other setup files I could find on the net, and so on - yet nothing worked.
Thanks in advance for any help :))
Reposting as an answer:
This is a bug that will be fixed in the next version of cx_Freeze. When it can't parse a code file as Python syntax, it tries to treat it as a compiled library, but that's not necessarily true (e.g. PyQt includes some separate files for Python 2 and 3). In the meantime, the simplest way to work around it is to apply the fix manually to your installed cx_Freeze, as described in this comment.