Reputation: 2379
I am trying to compile my Python 3.4 script into an executable for easy redistribution. I chose to use cxfreeze as it is one of the few that supports Python 3. However, when running the command to compile the script, I am getting the following error:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27
, in <module>
exec(code, m.__dict__)
File "C:\Users\kylec\Desktop\DataMotion\Python\MailChecker.py", line 1, in <mo
dule>
from tkinter import *
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2214, in _find_a
nd_load
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 2203, in _find_a
nd_load_unlocked
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_u
nlocked
File "c:\Python\64-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_b
ackward_compatible
AttributeError: 'module' object has no attribute '_fix_up_module'
But, I don't understand what's wrong other than it is complaining that _fix_up_module doesn't exist.
UPDATE:
Traceback (most recent call last):
File "cxfreeze", line 5, in <module>
main()
File "C:\Python34\lib\site-packages\cx_Freeze\main.py", line 187, in main
silent = options.silent)
File "C:\Python34\lib\site-packages\cx_Freeze\freezer.py", line 130, in __init
__
for n in self._GetDefaultBinPathExcludes() + binPathExcludes]
File "C:\Python34\lib\site-packages\cx_Freeze\freezer.py", line 270, in _GetDe
faultBinPathExcludes
import cx_Freeze.util
ImportError: DLL load failed: %1 is not a valid Win32 application.
Many other Q/A's suggest using the 32 bit version of cxfreeze. But I did as I downloaded this one: cx_Freeze‑4.3.3.win32‑py3.4.exe
If I compile using cxfreeze 64 bit I get no errors. However, the resultant exe does not run.
Upvotes: 0
Views: 2368
Reputation: 13
to add to @DigitalSage answer (which is perfectly good!)
I found issues with Python 3.6 and the new version of cxFreeze
Download Python 3.6 32 bit and it should work fine with the latest version of cxFreeze.
Also a good idea would be to look at virtualenv where you can have many different python environments on your machine that you can use. It saves you using the PATH Variable and possibly corrupting you installations.
Sometimes I have to use older versions of Python for backwards compatibility and it saves me a ton of headaches.
Upvotes: 0
Reputation: 11
This response pertains to Python 3.4 on a Windows 7 64-bit machine.
In my case, I had mixed 32-bit and 64-bit versions of Python and cx_Freeze. To fix, I completely uninstalled cx_Freeze and Python and reinstalled both, taking care to ensure that I downloaded and installed the proper 64-bit versions of each.
Prior to reinstalling, I had pywin32 installed as well. I removed it but did not reinstall it. I don't know if that had a hand in causing my issues or not (I have no need of it right now, anyway).
Upvotes: 1
Reputation: 2379
Thanks to all of Thomas K's hard work and timely responses we finally figured out the problem. I did indeed need 64 bit version of cxfreeze that matched my python installation. To make the Tkinter gui work, it is needed to add
root.mainloop()
to the bottom of your python file if you don't have it already.
Upvotes: 1