Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: 'str' does not support the buffer interface - python

I'm currently doing an online Python puzzle series, and I've gotten to a problem where you need to unload a pickled file. I read the documentation on it, but I kept getting

TypeError: 'str' does not support the buffer interface

...so I search on Google and arrive at a question on SO with a similar problem. The answer points to http://wiki.python.org/moin/UsingPickle .

I tried the code in the example and I'm getting the same problem? I'm using Python 3.2.2. WTF??

Complete Traceback :

Traceback (most recent call last):
  File "C:\foo.py", line 11, in <module>
    test1()
  File "C:\foo.py", line 9, in test1
    favorite_color = pickle.load( open( "save.p" ) )
TypeError: 'str' does not support the buffer interface

From the example here: http://wiki.python.org/moin/UsingPickle

I have already successfully created the save.p file with the first code example in the tutorial.

like image 219
mowwwalker Avatar asked Oct 01 '11 03:10

mowwwalker


1 Answers

Open the pickle file in binary mode: favorite_color = pickle.load(open("save.p", "rb")).

like image 111
Eryk Sun Avatar answered Oct 31 '22 07:10

Eryk Sun