473,320 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

pickle and py2exe

Hello,

Im trying to compile a script with py2exe. The pickle module is causing the
program to give an error.

Traceback (most recent call last):
File "SETIstat.pyw", line 330, in ?
File "SETIstat.pyw", line 84, in start_up
File "SETIstat.pyw", line 79, in config_load
File "pickle.pyc", line 1390, in load
File "pickle.pyc", line 872, in load
File "pickle.pyc", line 985, in load_string
LookupError: unknown encoding: string-escape

the data in the pickled file is a dictionary containing a couple strings. The
strings do contain \n and \t charaters but no other special characters or
anything.

Does anyone have any suggestions to what I can try to get around this? The
pickle module works fine when the .pyw file is run. Its only when I compile this
is there an issue.

Thanks for any help,

Justin
Jul 18 '05 #1
10 2647
I did this a while back, and I can't remember exactly. Therefore, I may only
be able to give you a push in the right direction until someone else can
answer it fully.

However, I think you have to force the db into the py2exe compile. I think
it's something like this:

--force-imports dbhash

Try this and see if it works.
"Justin Straube" <ju***********@charter.net> wrote in message
news:qp********************************@4ax.com...
Hello,

Im trying to compile a script with py2exe. The pickle module is causing
the
program to give an error.

Traceback (most recent call last):
File "SETIstat.pyw", line 330, in ?
File "SETIstat.pyw", line 84, in start_up
File "SETIstat.pyw", line 79, in config_load
File "pickle.pyc", line 1390, in load
File "pickle.pyc", line 872, in load
File "pickle.pyc", line 985, in load_string
LookupError: unknown encoding: string-escape

the data in the pickled file is a dictionary containing a couple strings.
The
strings do contain \n and \t charaters but no other special characters or
anything.

Does anyone have any suggestions to what I can try to get around this? The
pickle module works fine when the .pyw file is run. Its only when I
compile this
is there an issue.

Thanks for any help,

Justin

Jul 18 '05 #2
> Im trying to compile a script with py2exe. The pickle module is causing the
program to give an error.

Traceback (most recent call last):
File "SETIstat.pyw", line 330, in ?
File "SETIstat.pyw", line 84, in start_up
File "SETIstat.pyw", line 79, in config_load
File "pickle.pyc", line 1390, in load
File "pickle.pyc", line 872, in load
File "pickle.pyc", line 985, in load_string
LookupError: unknown encoding: string-escape

the data in the pickled file is a dictionary containing a couple strings. The
strings do contain \n and \t charaters but no other special characters or
anything.

Does anyone have any suggestions to what I can try to get around this? The
pickle module works fine when the .pyw file is run. Its only when I compile
this is there an issue.

Thanks for any help,

Justin


Have you included string-escape encoding in your setup.py?
My guess is that you can fix the problem with something similar to:

from distutils.core import setup
import py2exe
opts = { "py2exe": { "packages": ["encodings"], } }
setup(windows= ["spam.py"], options= opts)

in your setup.py.

Hope it helps
/Johan Lindberg
Jul 18 '05 #3
On Tue, 30 Nov 2004 22:48:39 -0600, "Catfish" <losnations@comca> wrote:
I did this a while back, and I can't remember exactly. Therefore, I may only
be able to give you a push in the right direction until someone else can
answer it fully.

However, I think you have to force the db into the py2exe compile. I think
it's something like this:

--force-imports dbhash

Try this and see if it works.
Thanks Catfish,

This brought up an error, option: --force-import not recognized.

While looking into this, I had seen some mention of protocol option in pickle. I
hadnt specified anything for protocol, so it defaults to 0 though I dont know
what that is. Its my first time using pickle and second with py2exe.

Thanks for the suggestion, Ill keep trying at this and another idea without
pickle.

Justin
"Justin Straube" <justinstraube@ch> wrote in message
news:qp********************************@4ax.com.. .
Hello,

Im trying to compile a script with py2exe. The pickle module is causing
the
program to give an error.

Traceback (most recent call last):
File "SETIstat.pyw", line 330, in ?
File "SETIstat.pyw", line 84, in start_up
File "SETIstat.pyw", line 79, in config_load
File "pickle.pyc", line 1390, in load
File "pickle.pyc", line 872, in load
File "pickle.pyc", line 985, in load_string
LookupError: unknown encoding: string-escape

the data in the pickled file is a dictionary containing a couple strings.
The
strings do contain \n and \t charaters but no other special characters or
anything.

Does anyone have any suggestions to what I can try to get around this? The
pickle module works fine when the .pyw file is run. Its only when I
compile this
is there an issue.

Thanks for any help,

Justin


Jul 18 '05 #4
On 1 Dec 2004 11:45:59 -0800, jo***@pulp.se (Johan Lindberg) wrote:

Have you included string-escape encoding in your setup.py?
My guess is that you can fix the problem with something similar to:

from distutils.core import setup
import py2exe
opts = { "py2exe": { "packages": ["encodings"], } }
setup(windows= ["spam.py"], options= opts)

in your setup.py.

Hope it helps
/Johan Lindberg


Thanks Johan, but unfortunately the same traceback is given in the log.
I should have mentioned in my previous post that Im using win2000, if it matters
any.

Thanks,

Justin
Im trying to compile a script with py2exe. The pickle module is causing the
program to give an error.

Traceback (most recent call last):
File "SETIstat.pyw", line 330, in ?
File "SETIstat.pyw", line 84, in start_up
File "SETIstat.pyw", line 79, in config_load
File "pickle.pyc", line 1390, in load
File "pickle.pyc", line 872, in load
File "pickle.pyc", line 985, in load_string
LookupError: unknown encoding: string-escape

the data in the pickled file is a dictionary containing a couple strings. The
strings do contain \n and \t charaters but no other special characters or
anything.

Does anyone have any suggestions to what I can try to get around this? The
pickle module works fine when the .pyw file is run. Its only when I compile
this is there an issue.

Thanks for any help,

Justin

Jul 18 '05 #5
On Tue, 30 Nov 2004 22:48:39 -0600, "Catfish" <losnations@comca> wrote:
I did this a while back, and I can't remember exactly. Therefore, I may only
be able to give you a push in the right direction until someone else can
answer it fully.

However, I think you have to force the db into the py2exe compile. I think
it's something like this:

--force-imports dbhash

Try this and see if it works.
Thanks Catfish,

This brought up an error, option: --force-import not recognized.

While looking into this, I had seen some mention of protocol option in pickle. I
hadnt specified anything for protocol, so it defaults to 0 though I dont know
what that is. Its my first time using pickle and second with py2exe.

Thanks for the suggestion, Ill keep trying at this and another idea without
pickle.

Justin
"Justin Straube" <justinstraube@ch> wrote in message
news:qp********************************@4ax.com.. .
Hello,

Im trying to compile a script with py2exe. The pickle module is causing
the
program to give an error.

Traceback (most recent call last):
File "SETIstat.pyw", line 330, in ?
File "SETIstat.pyw", line 84, in start_up
File "SETIstat.pyw", line 79, in config_load
File "pickle.pyc", line 1390, in load
File "pickle.pyc", line 872, in load
File "pickle.pyc", line 985, in load_string
LookupError: unknown encoding: string-escape

the data in the pickled file is a dictionary containing a couple strings.
The
strings do contain \n and \t charaters but no other special characters or
anything.

Does anyone have any suggestions to what I can try to get around this? The
pickle module works fine when the .pyw file is run. Its only when I
compile this
is there an issue.

Thanks for any help,

Justin


Jul 18 '05 #6
On 1 Dec 2004 11:45:59 -0800, jo***@pulp.se (Johan Lindberg) wrote:

Have you included string-escape encoding in your setup.py?
My guess is that you can fix the problem with something similar to:

from distutils.core import setup
import py2exe
opts = { "py2exe": { "packages": ["encodings"], } }
setup(windows= ["spam.py"], options= opts)

in your setup.py.

Hope it helps
/Johan Lindberg


Thanks Johan, but unfortunately the same traceback is given in the log.
I should have mentioned in my previous post that Im using win2000, if it matters
any.

Thanks,

Justin
Im trying to compile a script with py2exe. The pickle module is causing the
program to give an error.

Traceback (most recent call last):
File "SETIstat.pyw", line 330, in ?
File "SETIstat.pyw", line 84, in start_up
File "SETIstat.pyw", line 79, in config_load
File "pickle.pyc", line 1390, in load
File "pickle.pyc", line 872, in load
File "pickle.pyc", line 985, in load_string
LookupError: unknown encoding: string-escape

the data in the pickled file is a dictionary containing a couple strings. The
strings do contain \n and \t charaters but no other special characters or
anything.

Does anyone have any suggestions to what I can try to get around this? The
pickle module works fine when the .pyw file is run. Its only when I compile
this is there an issue.

Thanks for any help,

Justin

Jul 18 '05 #7
>>> Im trying to compile a script with py2exe. The pickle module is
causing the
program to give an error.

Traceback (most recent call last):
File "SETIstat.pyw", line 330, in ?
File "SETIstat.pyw", line 84, in start_up
File "SETIstat.pyw", line 79, in config_load
File "pickle.pyc", line 1390, in load
File "pickle.pyc", line 872, in load
File "pickle.pyc", line 985, in load_string
LookupError: unknown encoding: string-escape

the data in the pickled file is a dictionary containing a couple
strings. The
strings do contain \n and \t charaters but no other special characters or anything.

Does anyone have any suggestions to what I can try to get around this? The pickle module works fine when the .pyw file is run. Its only when I compile this is there an issue.

Thanks for any help,

Justin
Have you included string-escape encoding in your setup.py?
My guess is that you can fix the problem with something similar to:

from distutils.core import setup
import py2exe
opts = { "py2exe": { "packages": ["encodings"], } }
setup(windows= ["spam.py"], options= opts)

in your setup.py.

Hope it helps
/Johan Lindberg
Thanks Johan, but unfortunately the same traceback is given in the log.
I should have mentioned in my previous post that Im using win2000, if it
matters any.


Hi Justin.

I'm assuming that your library.zip now has several encoding-files in
it? And more specifically that you have a file called
"string_escape.pyc" in path "encodings". Right?

I don't think it's got anything to do with your windows version but it
might be helpful to know your python and py2exe versions.
Unfortunately I haven't been able to reproduce the error on either of
my windows machines (using python 2.3.4 and py2exe 0.5.3 on both, one
is win2k and the other XP).

Line 985 in pickle.py says:
self.append(rep.decode("string-escape"))
so that's why you need the encoding, even though you "don't use it".
Will the same lookup error show up in a smallest possible program,
such as:

# encoding= iso-8859-1
spam= "Det här är svenska"
print spam.decode("string-escape")

What happens when you compile that script to an exe using the above
setup.py?
(don't forget to change windows= ["spam.py"] to console= ["spam.py"])

Also you might want to try the py2exe-users list (see
http://aspn.activestate.com/ASPN/Mai.../py2exe-users).

BR
/Johan Lindberg
Jul 18 '05 #8
>>> Im trying to compile a script with py2exe. The pickle module is
causing the
program to give an error.

Traceback (most recent call last):
File "SETIstat.pyw", line 330, in ?
File "SETIstat.pyw", line 84, in start_up
File "SETIstat.pyw", line 79, in config_load
File "pickle.pyc", line 1390, in load
File "pickle.pyc", line 872, in load
File "pickle.pyc", line 985, in load_string
LookupError: unknown encoding: string-escape

the data in the pickled file is a dictionary containing a couple
strings. The
strings do contain \n and \t charaters but no other special characters or anything.

Does anyone have any suggestions to what I can try to get around this? The pickle module works fine when the .pyw file is run. Its only when I compile this is there an issue.

Thanks for any help,

Justin
Have you included string-escape encoding in your setup.py?
My guess is that you can fix the problem with something similar to:

from distutils.core import setup
import py2exe
opts = { "py2exe": { "packages": ["encodings"], } }
setup(windows= ["spam.py"], options= opts)

in your setup.py.

Hope it helps
/Johan Lindberg
Thanks Johan, but unfortunately the same traceback is given in the log.
I should have mentioned in my previous post that Im using win2000, if it
matters any.


Hi Justin.

I'm assuming that your library.zip now has several encoding-files in
it? And more specifically that you have a file called
"string_escape.pyc" in path "encodings". Right?

I don't think it's got anything to do with your windows version but it
might be helpful to know your python and py2exe versions.
Unfortunately I haven't been able to reproduce the error on either of
my windows machines (using python 2.3.4 and py2exe 0.5.3 on both, one
is win2k and the other XP).

Line 985 in pickle.py says:
self.append(rep.decode("string-escape"))
so that's why you need the encoding, even though you "don't use it".
Will the same lookup error show up in a smallest possible program,
such as:

# encoding= iso-8859-1
spam= "Det här är svenska"
print spam.decode("string-escape")

What happens when you compile that script to an exe using the above
setup.py?
(don't forget to change windows= ["spam.py"] to console= ["spam.py"])

Also you might want to try the py2exe-users list (see
http://aspn.activestate.com/ASPN/Mai.../py2exe-users).

BR
/Johan Lindberg
Jul 18 '05 #9
> While looking into this, I had seen some mention of protocol option in pickle. I
hadnt specified anything for protocol, so it defaults to 0 though I dont know
what that is. Its my first time using pickle and second with py2exe.


If you think this might be your problem, then it would be best to
specify your protocol using the variable HIGHEST_PROTOCOL as defined
in the Pickle module. However, if this does fix your problem, keep in
mind it won't fix the problem for earlier pickle versions.

Bickett
Jul 18 '05 #10
On 3 Dec 2004 01:46:38 -0800, johan@ (Johan Lindberg) wrote:

Thanks Johan,
I'm assuming that your library.zip now has several encoding-files in
it? And more specifically that you have a file called
"string_escape.pyc" in path "encodings". Right?
I had found a stupid mistake in my setup.py. I corrected it and the .zip now has
the string_escape.pyc file in the correct path. And also the program runs as it
should.
# encoding= iso-8859-1
spam= "Det här är svenska"
print spam.decode("string-escape")

What happens when you compile that script to an exe using the above
setup.py?
(don't forget to change windows= ["spam.py"] to console= ["spam.py"])
This gives a LookupError: no codec search function registered: can't find
encoding

I then tried with the encoding package added and the .exe did print the spam
string.
Also you might want to try the py2exe-users list (see
http://aspn.activestate.com/ASPN/Mai.../py2exe-users).


Thanks, Ill check this out.
Regards,
Justin Straube
Jul 18 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: RJS | last post by:
Hi all, I can't get a py2exe compiled app to run with numarray (numarray-0.5.win32- py2.2). Also wxPythonWIN32-2.3.3.1-Py22 and ActivePython-2.2.1-222. In the sample below, commenting out...
6
by: Luc Saffre | last post by:
Hello, I had a strange problem when freezing (using either py2exe or McMillan installer) a script that imports reportlab (which imports PIL (which imports FixTk))). - Python 2.3.3c (also with...
3
by: Michael Hohn | last post by:
Hi, under python 2.2, the pickle/unpickle sequence incorrectly restores a larger data structure I have. Under Python 2.3, these structures now give an explicit exception from...
0
by: Mike P. | last post by:
Hi all, I'm working on a simulation (can be considered a game) in Python where I want to be able to dump the simulation state to a file and be able to load it up later. I have used the standard...
6
by: Jim Lewis | last post by:
Pickling an instance of a class, gives "can't pickle instancemethod objects". What does this mean? How do I find the class method creating the problem?
10
by: crystalattice | last post by:
I'm creating an RPG for experience and practice. I've finished a character creation module and I'm trying to figure out how to get the file I/O to work. I've read through the python newsgroup...
5
by: Chris | last post by:
Why can pickle serialize references to functions, but not methods? Pickling a function serializes the function name, but pickling a staticmethod, classmethod, or instancemethod generates an...
3
by: fizilla | last post by:
Hello all! I have the following weird problem and since I am new to Python I somehow cannot figure out an elegant solution. The problem reduces to the following question: How to pickle a...
1
by: IceMan85 | last post by:
Hi to all, I have spent the whole morning trying, with no success to pickle an object that I have created. The error that I get is : Can't pickle 'SRE_Match' object: <_sre.SRE_Match object at...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.