# A question of using pickle on CPX

**URL:** <https://forums.digi.com/t/a-question-of-using-pickle-on-cpx/3385>\
**Category:** Python\
**Created:** [October 12, 2009, 12:50pm UTC](https://forums.digi.com/t/a-question-of-using-pickle-on-cpx/3385 "2009-10-12T12:50:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tommytino](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@tommytino](https://forums.digi.com/u/tommytino)\
**Post date:** [October 12, 2009, 12:50pm UTC](https://forums.digi.com/t/a-question-of-using-pickle-on-cpx/3385/1 "2009-10-12T12:50:53Z")

</div>

I tried to use pickle module in Python 2.4 library to store dictionary to a file for a data storage. However, I got problem when I read it back my pickle. I got the error message from the CPX.

Traceback (most recent call last):  
File “./threading.py”, line 442, in \_\_bootstrap  
File “src\devices\abc.py”, line 327, in run  
File “src\devices\abc.py”, line 249, in read\_log  
File “C:\Python24\Lib\pickle.py”, line 1390, in load  
File “C:\Python24\Lib\pickle.py”, line 872, in load  
File “C:\Python24\Lib\pickle.py”, line 985, in load\_string  
LookupError: unknown encoding: string-escape

I know that the default make.py doesn’t include the pickle.py and encodings\string\_escape.py. So, I modified the make.py to complie these two files into dia.zip.

ALWAYS\_ADD = (  
os.path.join(PYTHON\_LIB, “encodings/ascii.py”),  
os.path.join(PYTHON\_LIB, “encodings/utf\_8.py”),  
os.path.join(PYTHON\_LIB, “encodings/string\_escape.py”),  
os.path.join(PYTHON\_LIB, “pickle.py”),

# “src/channels”,

# “src/devices”,

# “src/presentations”,

```
         )

```

However, I still found a lookup problem “LookupError: unknown encoding: string-escape”. Could you tell me what the problem is?

Thanks

---

<div class="post-metadata">

**Author:** ![scottk](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@scottk](https://forums.digi.com/u/scottk)\
**Post date:** [October 13, 2009, 12:18am UTC](https://forums.digi.com/t/a-question-of-using-pickle-on-cpx/3385/2 "2009-10-13T00:18:28Z")

</div>

Try packing it into Dia at the toplevel instead of inside the “encodings” directory.

For myself, I ended up doing this extra command after building dia (under Linux):

zip bin/dia.zip -j /usr/lib/python2.4/encodings/string\_escape.pyc

---

<div class="post-metadata">

**Author:** ![tommytino](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@tommytino](https://forums.digi.com/u/tommytino)\
**Post date:** [October 13, 2009, 1:41am UTC](https://forums.digi.com/t/a-question-of-using-pickle-on-cpx/3385/3 "2009-10-13T01:41:09Z")

</div>

Hi Scottk,

Thanks for your suggestion and you gave me an idea. I modified the code of “dia.py” and modified two statements in there.

…  
sys.path.insert(0, os.path.join(DIGI\_DIA\_ARCHIVE, “encodings”))  
…  
for path in [‘./lib’, ‘./src’,‘./encodings’]:  
…

It works after I changed the code and I think that it is related to the path issue.

Thanks for help 🙂
