Friday, 9 August 2013

converting python program into executable

converting python program into executable

So now, I have a python program which I would like to convert into an
executable(preferably a single file). Right now the target systems are
only RedHat(and CentOS) and Debian(and Ubuntu).
First, I've tried the PyInstaller but after running it, it creates a .spec
file and 2 folders called build and dist. I have no idea how to proceed
from there.
Second, I tried the freeze.py which ships with python. I understand the
usage is as follows:
python /path/to/freeze.py /path/to/myfile.py
This throws an error ***Test Failed*** 2 failures and NameError: name
'testdata' is not defined
The full error is as follows:
**********************************************************************
File "/usr/lib/python2.6/site-packages/freeze.py", line 117, in
__main__.freeze
Failed example:
testdata = json.loads(
gzip.open("testdata.json.gz", "r").read().decode()
)
Exception raised:
Traceback (most recent call last):
File "/usr/lib64/python2.6/doctest.py", line 1253, in __run
compileflags, 1) in test.globs
File "<doctest __main__.freeze[3]>", line 2, in <module>
gzip.open("testdata.json.gz", "r").read().decode()
File "/usr/lib64/python2.6/gzip.py", line 33, in open
return GzipFile(filename, mode, compresslevel)
File "/usr/lib64/python2.6/gzip.py", line 79, in __init__
fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
IOError: [Errno 2] No such file or directory: 'testdata.json.gz'
**********************************************************************
File "/usr/lib/python2.6/site-packages/freeze.py", line 121, in
__main__.freeze
Failed example:
freeze(testdata) == freeze_fast(testdata)
Exception raised:
Traceback (most recent call last):
File "/usr/lib64/python2.6/doctest.py", line 1253, in __run
compileflags, 1) in test.globs
File "<doctest __main__.freeze[4]>", line 1, in <module>
freeze(testdata) == freeze_fast(testdata)
NameError: name 'testdata' is not defined
**********************************************************************
1 items had failures:
2 of 8 in __main__.freeze
***Test Failed*** 2 failures.
I'd like some help to using either of the 2 (or any other tool which will
help me achieve the same result).
Thanks.

No comments:

Post a Comment