ValueError: insecure pickle string

Discussion in 'Python' started by pradeepbpin, Mar 28, 2011.

  1. pradeepbpin

    pradeepbpin Guest

    I am encountering 'Value Error: insecure string pickle' when trying to
    execute the script on Ubuntu. The same script and the pickled file
    works without any problem in Windows. For working in Ubuntu I just
    copied both the script file and pickled file from Windows.


    How can I get out of this error? Rather, I would like to have common
    script and pickled file that can work platform independently.
     
    pradeepbpin, Mar 28, 2011
    #1
    1. Advertising

  2. pradeepbpin

    Peter Otten Guest

    pradeepbpin wrote:

    > I am encountering 'Value Error: insecure string pickle' when trying to
    > execute the script on Ubuntu. The same script and the pickled file
    > works without any problem in Windows. For working in Ubuntu I just
    > copied both the script file and pickled file from Windows.
    >
    >
    > How can I get out of this error? Rather, I would like to have common
    > script and pickled file that can work platform independently.


    Try opening the file in universal newline mode:

    f = open("my.pickle", "U")
    print pickle.load(f)

    This will convert Windows "\r\n" line endings to "\n".

    For new data: an alternative is to open the file in binary mode for both
    reading and writing on all platforms. This will also allow you to switch to
    the more efficient binary pickle protocols.
     
    Peter Otten, Mar 28, 2011
    #2
    1. Advertising

  3. On Mon, 28 Mar 2011 08:53:35 -0700, pradeepbpin wrote:

    > I am encountering 'Value Error: insecure string pickle' when trying to
    > execute the script on Ubuntu. The same script and the pickled file works
    > without any problem in Windows. For working in Ubuntu I just copied both
    > the script file and pickled file from Windows.


    What version of Python are you using on Ubuntu? Is it the same version of
    Python on Windows?

    Please show the full error traceback and the string that causes the error.




    --
    Steven
     
    Steven D'Aprano, Mar 28, 2011
    #3
  4. pradeepbpin

    pradeepbpin Guest


    > For new data: an alternative is to open the file in binary mode for both
    > reading and writing on all platforms. This will also allow you to switch to
    > the more efficient binary pickle protocols.


    Writing and reading the pickled file in binary mode seems to be
    working. Thank you.
     
    pradeepbpin, Mar 28, 2011
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. a pickle's pickle

    , Aug 2, 2005, in forum: Python
    Replies:
    4
    Views:
    388
  2. robert
    Replies:
    2
    Views:
    467
    Steve Holden
    Sep 11, 2007
  3. -dresden.de
    Replies:
    2
    Views:
    508
    Peter Otten
    Mar 12, 2008
  4. Michele Simionato
    Replies:
    2
    Views:
    1,889
    Michele Simionato
    May 23, 2008
  5. Alexander Eisenhuth
    Replies:
    4
    Views:
    1,058
    Alexander Eisenhuth
    Jul 14, 2010
Loading...

Share This Page