pickle problems - ImportError: No module named __builtin__

2,148 views
Skip to first unread message

Scott

unread,
Dec 16, 2009, 10:18:02 PM12/16/09
to Google App Engine
I am trying to execute the following code:

path = os.path.join(os.getcwd(), 'applications', 'default', 'modules')

word_set_a = pickle.load(open(os.path.join(path, 'word_set_a.txt'),
'r'))

But I am getting the following error:

Traceback (most recent call last):
File "/base/data/home/apps/hillmanwork/1.338501969210326694/gluon/
restricted.py", line 173, in restricted
exec ccode in environment
File "/base/data/home/apps/hillmanwork/1.338501969210326694/
applications/default/controllers/boggle.py:findWords", line 18, in
<module>
File "/base/data/home/apps/hillmanwork/1.338501969210326694/gluon/
globals.py", line 96, in <lambda>
self._caller = lambda f: f()
File "/base/data/home/apps/hillmanwork/1.338501969210326694/
applications/default/controllers/boggle.py:findWords", line 6, in
findWords
File "/base/data/home/apps/hillmanwork/1.338501969210326694/
applications/default/modules/pyBoggle.py", line 88, in <module>
word_set_a = pickle.load(open(os.path.join(path,
'word_set_a.txt'), 'r'))
File "/base/python_dist/lib/python2.5/pickle.py", line 1363, in load
return Unpickler(file).load()
File "/base/python_dist/lib/python2.5/pickle.py", line 852, in load
dispatch[key](self)
File "/base/python_dist/lib/python2.5/pickle.py", line 1084, in
load_global
klass = self.find_class(module, name)
File "/base/python_dist/lib/python2.5/pickle.py", line 1117, in
find_class
__import__(module)
ImportError: No module named __builtin__

Everything works just fine on the local test server, but once upload I
have not such luck.

Are there limitations with the pickle module that I am not aware of?


Wesley Chun

unread,
Dec 17, 2009, 4:25:11 AM12/17/09
to google-a...@googlegroups.com
scott,

how is the variable 'path' created? since App Engine executes in a
restricted environment, you may not have access to the necessary
files. a call to os.path.join() should have a flavor of
os.path.join(os.path.dirname(__file__), ...

pickle should be pretty much as you would expect except that it's
really "cPickle," as stated in the docs:
http://code.google.com/appengine/kb/general.html
http://code.google.com/appengine/docs/python/runtime.html

best regards,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
"Python Fundamentals", Prentice Hall, (c)2009
http://corepython.com

wesley.j.chun : we...@google.com
developer relations, google app engine

Scott

unread,
Dec 17, 2009, 4:34:21 PM12/17/09
to Google App Engine
What I was trying to do was unpickle a set object containing words
starting with the letter 'a'. I dropped the pickle idea and just
opened up a text file with those same words and put them in a set as I
read them in

The path variable is correct - I didn't need to change it to get to my
files. The problem was with trying to unpickle. Not sure why, but I
did get things working by ditching the pickle approach.

Just got it working a few hours ago -

Thanks for your response.


On Dec 17, 2:25 am, Wesley Chun <w...@google.com> wrote:
> scott,
>
> how is the variable 'path' created? since App Engine executes in a
> restricted environment, you may not have access to the necessary
> files. a call to os.path.join() should have a flavor of
> os.path.join(os.path.dirname(__file__), ...
>
> pickle should be pretty much as you would expect except that it's

> really "cPickle," as stated in the docs:http://code.google.com/appengine/kb/general.htmlhttp://code.google.com/appengine/docs/python/runtime.html


>
> best regards,
> -- wesley
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> "Core Python Programming", Prentice Hall, (c)2007,2001
> "Python Fundamentals", Prentice Hall, (c)2009
>    http://corepython.com
>

> wesley.j.chun : w...@google.com

Andy Freeman

unread,
Dec 18, 2009, 7:31:50 PM12/18/09
to Google App Engine
> pickle should be pretty much as you would expect except that it's
> really "cPickle," as stated in the docs:http://code.google.com/appengine/kb/general.html

If pickle is really cPickle, then why are the cPickle specific
features not available?


On Dec 17, 1:25 am, Wesley Chun <w...@google.com> wrote:
> scott,
>
> how is the variable 'path' created? since App Engine executes in a
> restricted environment, you may not have access to the necessary
> files. a call to os.path.join() should have a flavor of
> os.path.join(os.path.dirname(__file__), ...
>
> pickle should be pretty much as you would expect except that it's

> really "cPickle," as stated in the docs:http://code.google.com/appengine/kb/general.htmlhttp://code.google.com/appengine/docs/python/runtime.html


>
> best regards,
> -- wesley
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> "Core Python Programming", Prentice Hall, (c)2007,2001
> "Python Fundamentals", Prentice Hall, (c)2009
>    http://corepython.com
>

> wesley.j.chun : w...@google.com

> > Are there limitations with the pickle module that I am not aware of?- Hide quoted text -
>
> - Show quoted text -

Reply all
Reply to author
Forward
0 new messages