No encodings after freezing

M

mmf

Hi.

I have the following script (for example):

#!/usr/bin/python
text = 'Hallo'
text_new = text.encode('utf_8')
print text_new

The I tried to "freeze" this script with cx_freeze 3.0.1 (command
../FreezePython example.py).
Everything worked finde, a binary was created correctly.

But everytime I run this binary the utf-8 encoding cannot be found.
(Also any other encoding like iso8859_15 cannot be found...)

What am I doing wrong?
Thank.

Best regards,
Markus
 
?

=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=

mmf said:
text_new = text.encode('utf_8') [...]
But everytime I run this binary the utf-8 encoding cannot be found.
(Also any other encoding like iso8859_15 cannot be found...)

What am I doing wrong?

Codecs are modules (in the encodings package). So if the codecs
you need aren't frozen, they aren't available at run-time. OTOH,
freeze cannot "see" the import (since it doesn't know that the
argument to .encode is really similar to a module name), so
it won't include the modules. You need to give it an explicit
list of encodings you want to freeze.

Most likely, there is some explicit command line argument, but
alternatively, you could also put

if 0:
import encodings.utf_8
import encodings.iso8859_1
# etc

into some source file.

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,240
Messages
2,571,205
Members
47,844
Latest member
ChanceGris

Latest Threads

Top