Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating a standalone application

41 views
Skip to first unread message

Luis Quesada

unread,
Apr 13, 2010, 5:02:07 PM4/13/10
to
Dear all,
I am getting an "expected string without null bytes" error when using
cxfreeze for creating a standalone application (in Linux-Ubuntu). None
of my files has null bytes. I also tried pyinstaller but I got the error
attached at the end.
My program runs fine when executed from eclipse. What is the easiest
way of creating a standalone application? Is there a way of creating the
executable file from eclipse/pydev?
Cheers,
Luis

cxfreeze's output
lquesada@lquesada-laptop:~/workspace/MetroNode/src/models$ cxfreeze
uncovered.py --target-dir dist
copying /usr/lib/pymodules/python2.6/cx_Freeze/bases/Console ->
dist/uncovered
copying /usr/lib/libpython2.6.so.1.0 -> dist/libpython2.6.so.1.0
Traceback (most recent call last):
File "/usr/bin/cxfreeze", line 5, in <module>
main()
File "/usr/lib/pymodules/python2.6/cx_Freeze/main.py", line 170, in main
freezer.Freeze()
File "/usr/lib/pymodules/python2.6/cx_Freeze/freezer.py", line 405,
in Freeze
self._FreezeExecutable(executable)
File "/usr/lib/pymodules/python2.6/cx_Freeze/freezer.py", line 173,
in _FreezeExecutable
exe.copyDependentFiles, scriptModule)
File "/usr/lib/pymodules/python2.6/cx_Freeze/freezer.py", line 333,
in _WriteModules
initModule = finder.IncludeFile(initScript, "cx_Freeze__init__")
File "/usr/lib/pymodules/python2.6/cx_Freeze/finder.py", line 386, in
IncludeFile
deferredImports)
File "/usr/lib/pymodules/python2.6/cx_Freeze/finder.py", line 259, in
_LoadModule
module.code = compile(fp.read() + "\n", path, "exec")
TypeError: compile() expected string without null bytes
lquesada@lquesada-laptop:~/workspace/MetroNode/src/models$

======================================================================
pyinstaller's output

lquesada@lquesada-laptop:~/workspace/MetroNode/src/models$ python
~/pyinstaller-1.4/Build.py uncovered.spec
checking Analysis
building Analysis because outAnalysis0.toc non existent
running Analysis outAnalysis0.toc
Analyzing: /home/lquesada/pyinstaller-1.4/support/_mountzlib.py
Analyzing: /home/lquesada/pyinstaller-1.4/support/useUnicode.py
Analyzing: uncovered.py
ldd:
/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_conflict.so:
No such file or directory
ldd:
/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_nodesel.so:
No such file or directory
ldd:
/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_vars.so:
No such file or directory
ldd:
/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_heur.so:
No such file or directory
ldd:
/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_branch.so:
No such file or directory
ldd:
/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_sepa.so:
No such file or directory
ldd:
/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_prop.so:
No such file or directory
ldd:
/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_presol.so:
No such file or directory
ldd:
/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_soln.so:
No such file or directory
ldd:
/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_cons.so:
No such file or directory
ldd:
/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_scip.so:
No such file or directory
Warnings written to
/home/lquesada/workspace/MetroNode/src/models/warnuncovered.txt
checking PYZ
rebuilding outPYZ1.toc because outPYZ1.pyz is missing
building PYZ outPYZ1.toc
checking PKG
rebuilding outPKG3.toc because outPKG3.pkg is missing
building PKG outPKG3.pkg
Cannot find ('zibopt._conflict.so',
'/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_conflict.so',
1, 'b')
Traceback (most recent call last):
File "/home/lquesada/pyinstaller-1.4/Build.py", line 1160, in <module>
main(args[0], configfilename=opts.configfile)
File "/home/lquesada/pyinstaller-1.4/Build.py", line 1148, in main
build(specfile)
File "/home/lquesada/pyinstaller-1.4/Build.py", line 1111, in build
execfile(spec)
File "uncovered.spec", line 14, in <module>
console=1 )
File "/home/lquesada/pyinstaller-1.4/Build.py", line 661, in __init__
strip_binaries=self.strip, upx_binaries=self.upx, crypt=self.crypt)
File "/home/lquesada/pyinstaller-1.4/Build.py", line 561, in __init__
self.__postinit__()
File "/home/lquesada/pyinstaller-1.4/Build.py", line 196, in __postinit__
self.assemble()
File "/home/lquesada/pyinstaller-1.4/Build.py", line 618, in assemble
archive.build(self.name, mytoc)
File "/home/lquesada/pyinstaller-1.4/archive.py", line 229, in build
self.add(tocentry) # the guts of the archive
File "/home/lquesada/pyinstaller-1.4/carchive.py", line 235, in add
s = open(pathnm, 'rb').read()
IOError: [Errno 20] Not a directory:
'/usr/local/lib/python2.6/dist-packages/python_zibopt-0.5.beta_r97-py2.6-linux-i686.egg/zibopt/_conflict.so'

Lawrence D'Oliveiro

unread,
Apr 13, 2010, 5:42:35 PM4/13/10
to
In message <kZ4xn.868$I8....@news.indigo.ie>, Luis Quesada wrote:

> I am getting an "expected string without null bytes" error when using
> cxfreeze for creating a standalone application (in Linux-Ubuntu).

Why bother? Every decent Linux system will have Python available. Why not
just distribute it as a script?

Luis Quesada

unread,
Apr 13, 2010, 6:11:35 PM4/13/10
to

Well every decent Linux system will have Java available too but it is
still preferable to distribute jar files. The point is that I don't want
to force my users to install all the packages that I had to install.
Cheers,
Luis

Gabriel Genellina

unread,
Apr 14, 2010, 1:31:17 AM4/14/10
to pytho...@python.org
En Tue, 13 Apr 2010 18:02:07 -0300, Luis Quesada <l.qu...@4c.ucc.ie>
escribi�:

> I am getting an "expected string without null bytes" error when using
> cxfreeze for creating a standalone application (in Linux-Ubuntu). None
> of my files has null bytes.

Are you sure? A text file saved as, e.g., UTF-16, does contain null bytes.

> cxfreeze's output
> ...


> File "/usr/lib/pymodules/python2.6/cx_Freeze/finder.py", line 386, in
> IncludeFile
> deferredImports)
> File "/usr/lib/pymodules/python2.6/cx_Freeze/finder.py", line 259, in
> _LoadModule
> module.code = compile(fp.read() + "\n", path, "exec")
> TypeError: compile() expected string without null bytes

I would add a few 'print' statements in finder.py to determine which file
is failing.

--
Gabriel Genellina

Jonathan Hartley

unread,
Apr 14, 2010, 4:24:54 AM4/14/10
to
On Apr 13, 10:42 pm, Lawrence D'Oliveiro <l...@geek-

I keep hearing this reply every time I ask this question, and it
doesn't seem to make sense to me.

Anything other than a trivial script will have dependencies. These
might be other Python packages, C-extensions, and other libraries.
What if your program runs on a version of Python other than the one
installed on the client's Linux system?

In my opinion, there is a severe need for this question to be answered
in a robust and simple way. Is creating an rpm / deb file the answer?
I don't know, but I think it's a very valid question.

Luis Quesada

unread,
Apr 14, 2010, 5:10:59 AM4/14/10
to
On Apr 14, 6:31 am, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
> En Tue, 13 Apr 2010 18:02:07 -0300, Luis Quesada <l.ques...@4c.ucc.ie>  

I did what you suggested: I modified finder.py so that it prints the
name of the module before the compile statement that triggers the
exception. This is what I get now:

lquesada@lquesada-laptop:~/workspace/MetroNode/src/models$ cxfreeze
uncovered.py --target-dir dist

compiling os
compiling posixpath
compiling stat
compiling genericpath
compiling warnings
compiling linecache
compiling types
compiling re
compiling sre_compile
compiling sre_parse
compiling sre_constants
compiling copy_reg
compiling UserDict
compiling _abcoll
compiling abc
compiling copy
compiling repr
compiling subprocess
compiling traceback
compiling threading
compiling functools
compiling _strptime
compiling locale
compiling encodings
compiling codecs
compiling encodings.aliases
compiling calendar
compiling optparse
compiling textwrap
compiling string
compiling gettext
compiling struct
compiling StringIO
compiling token
compiling tokenize
compiling dummy_thread
compiling collections
compiling keyword
compiling doctest
compiling __future__
compiling inspect
compiling dis
compiling opcode
compiling unittest
compiling getopt
compiling difflib
compiling heapq
compiling bisect
compiling pdb
compiling cmd
compiling bdb
compiling pprint
compiling shlex
compiling tempfile
compiling random
compiling _threading_local
compiling pickle
compiling __main__
compiling Numberjack
compiling Decomp
copying /usr/lib/pymodules/python2.6/cx_Freeze/bases/Console -> dist/
uncovered
copying /usr/lib/libpython2.6.so.1.0 -> dist/libpython2.6.so.1.0
compiling cx_Freeze__init__


Traceback (most recent call last):
File "/usr/bin/cxfreeze", line 5, in <module>
main()
File "/usr/lib/pymodules/python2.6/cx_Freeze/main.py", line 170, in
main
freezer.Freeze()
File "/usr/lib/pymodules/python2.6/cx_Freeze/freezer.py", line 405,
in Freeze
self._FreezeExecutable(executable)
File "/usr/lib/pymodules/python2.6/cx_Freeze/freezer.py", line 173,
in _FreezeExecutable
exe.copyDependentFiles, scriptModule)
File "/usr/lib/pymodules/python2.6/cx_Freeze/freezer.py", line 333,
in _WriteModules
initModule = finder.IncludeFile(initScript, "cx_Freeze__init__")

File "/usr/lib/pymodules/python2.6/cx_Freeze/finder.py", line 387,
in IncludeFile
deferredImports)
File "/usr/lib/pymodules/python2.6/cx_Freeze/finder.py", line 260,


in _LoadModule
module.code = compile(fp.read() + "\n", path, "exec")
TypeError: compile() expected string without null bytes

Now I even more confused since it seems the problem is taking place
when trying cx_Freeze__init__ ....
Cheers,
Luis

Gabriel Genellina

unread,
Apr 14, 2010, 6:06:14 AM4/14/10
to pytho...@python.org
En Wed, 14 Apr 2010 06:10:59 -0300, Luis Quesada
<luis.omar.qu...@gmail.com> escribió:

> On Apr 14, 6:31 am, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
> wrote:
>> En Tue, 13 Apr 2010 18:02:07 -0300, Luis Quesada <l.ques...@4c.ucc.ie>
>> escribi :
>>
>> > I am getting an "expected string without null bytes" error when using
>> > cxfreeze for creating a standalone application (in Linux-Ubuntu). >
>> None > of my files has null bytes.

> This is what I get now:
> ...


> compiling cx_Freeze__init__
> Traceback (most recent call last):

> ...


> File "/usr/lib/pymodules/python2.6/cx_Freeze/finder.py", line 260,
> in _LoadModule
> module.code = compile(fp.read() + "\n", path, "exec")
> TypeError: compile() expected string without null bytes
>
> Now I even more confused since it seems the problem is taking place
> when trying cx_Freeze__init__ ....

Yes, looks like a problem within cx_Freeze itself. Sorry, I cannot be of
more help, I don't use the tool myself.

Try asking in the project's mailing list
<http://cx-freeze.sourceforge.net>, I think you may get more specific help
there. (Also, try using the latest cx_Freeze release, this may have been
already fixed).

--
Gabriel Genellina

Luis Quesada

unread,
Apr 14, 2010, 6:20:35 AM4/14/10
to
On Apr 14, 11:06 am, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:

> En Wed, 14 Apr 2010 06:10:59 -0300, Luis Quesada  
> <luis.omar.quesada.rami...@gmail.com> escribió:

Thanks Gabriel. I will try cx-freeze's mailing list.
Cheers
Luis

Lawrence D'Oliveiro

unread,
Apr 17, 2010, 7:20:37 AM4/17/10
to
In message <fbdf4a20-1fe2-4c23-9ee2-

c6e739...@12g2000yqi.googlegroups.com>, Jonathan Hartley wrote:

> On Apr 13, 10:42�pm, Lawrence D'Oliveiro

> <l...@geek-central.gen.new_zealand> wrote:
>
>> In message <kZ4xn.868$I8....@news.indigo.ie>, Luis Quesada wrote:
>>
>> > I am getting an "expected string without null bytes" error when using
>> > cxfreeze for creating a standalone application (in Linux-Ubuntu).
>>
>> Why bother? Every decent Linux system will have Python available. Why not
>> just distribute it as a script?
>

> Anything other than a trivial script will have dependencies. These
> might be other Python packages, C-extensions, and other libraries.
> What if your program runs on a version of Python other than the one
> installed on the client's Linux system?

Let the distro maintainers worry about that. They will package your code up
in the appropriate form, so that the system package manager will
automatically ensure that the right dependencies are present. Problem
solved, no need to keep reinventing the wheel.

Lawrence D'Oliveiro

unread,
Apr 17, 2010, 7:21:24 AM4/17/10
to
In message <4BC4EC17...@4c.ucc.ie>, Luis Quesada wrote:

> Lawrence D'Oliveiro wrote:
>
>> In message <kZ4xn.868$I8....@news.indigo.ie>, Luis Quesada wrote:
>>
>>> I am getting an "expected string without null bytes" error when using
>>> cxfreeze for creating a standalone application (in Linux-Ubuntu).
>>
>> Why bother? Every decent Linux system will have Python available. Why not
>> just distribute it as a script?
>

> Well every decent Linux system will have Java available too ...

Questionable. Java doesn’t seem to be of much importance in the mass market,
it seems to be primarily for corporate use.

0 new messages