I finally got a piece of code I wrote into what seems to be a somewhat executable style. I ran into an error on execution:
Fatal Python error: initfsencoding: unable to load the file system codec
ImportError: invalid flags 1540019631 in 'encodings'
Current thread 0x00007fff77a44000 (most recent call first):
Abort trap: 6
I've tried using cx_Freeze to convert my script to an executable. The cx_Freeze seemed to work, and I got a file in the correct folder.
But, upon trying to execute it I got the above error. I found a fix here:
and found the
freezer.py
file. But, do I add the code in the code directly to this file at the very beginning or am I seeking specific sequences to insert it? When I put it at the beginning of the freezer.py file, I get a series of errors related to the freezer.py file that now prevent converting to executable.
I appreciate any help you all could offer, sorry for the really lame question!
Basically I inserted
cx_Freeze-5.1.1/cx_Freeze/freezer.py 2018-08-05 17:53:44.557771000 +0300
@@ -550,13 +550,18 @@
# the file is up to date so we can safely set this value to zero
if module.code is not None:
if module.file is not None and os.path.exists(module.file):
stat = os.stat(module.file)
mtime = stat.st_mtime
size = stat.st_size & 0xFFFFFFFF
else:
mtime = time.time()
size = 0
if sys.version_info[:2] < (3, 3):
header = magic + struct.pack("<i", int(mtime))
elif sys.version_info[:2] < (3, 7):
header = magic + struct.pack("<ii", int(mtime), 0)
else:
header = magic + struct.pack("<iii", 0, int(mtime), size)
data = header + marshal.dumps(module.code)
right after the import cx_Freeze in the freezer.py
I expected successful conversion and an executable, but I got the following error:
Fatal Python error: initfsencoding: unable to load the file system codec
ImportError: invalid flags 1540019631 in 'encodings'
Current thread 0x00007fff77a44000 (most recent call first):
Abort trap: 6
After trying to integrate the fix, I got the following error BEFORE any conversion had occurred:
Traceback (most recent call last):
File "setup.py", line 2, in <module>
from cx_Freeze import setup, Executable
File "/Users/ashley/Library/Python/3.7/lib/python/site-packages/cx_Freeze/__init__.py", line 11, in <module>
from cx_Freeze.freezer import *
File "/Users/ashley/Library/Python/3.7/lib/python/site-packages/cx_Freeze/freezer.py", line 22
cx_Freeze-5.1.1/cx_Freeze/freezer.py 2018-08-05 17:53:44.557771000 +0300
^
SyntaxError: invalid syntax
Not sure how to properly integrate the fix :(
User contributions licensed under CC BY-SA 3.0