Can't Pickle error upon trying to save [solved]

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
needchocolatenow
Newbie
Posts: 10
Joined: Sun Aug 27, 2017 12:44 pm
Tumblr: https://chocodevs.tumblr.com/
itch: chocomarimo.
Contact:

Can't Pickle error upon trying to save [solved]

#1 Post by needchocolatenow » Wed Sep 06, 2017 9:34 pm

Hi, I'm fairly new to coding and I've come across something that's been making me scratch my head. I'm not sure how to fix it or what I've done wrong. The game runs fine, but saving brings up this error. Perhaps someone can explain to me what I've done wrong?

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00gamemenu.rpy", line 173, in script
    $ ui.interact()
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
  File "renpy/common/00action_file.rpy", line 357, in __call__
    renpy.save(fn, extra_info=save_name)
PicklingError: Can't pickle <function pickNotebook at 0x1055c8488>: it's not the same object as store.pickNotebook

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/00gamemenu.rpy", line 173, in script
    $ ui.interact()
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/ast.py", line 805, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/python.py", line 1641, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/ui.py", line 278, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/core.py", line 2496, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/core.py", line 3172, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 928, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/transition.py", line 45, in event
    return self.new_widget.event(ev, x, y, st) # E1101
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 928, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 928, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/screen.py", line 646, in event
    rv = self.child.event(ev, x, y, st)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 928, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 204, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 928, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 204, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 928, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 204, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/behavior.py", line 868, in event
    return handle_click(self.clicked)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/behavior.py", line 803, in handle_click
    rv = run(action)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/behavior.py", line 302, in run
    return action(*args, **kwargs)
  File "renpy/common/00action_file.rpy", line 357, in __call__
    renpy.save(fn, extra_info=save_name)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/loadsave.py", line 281, in save
    dump((roots, renpy.game.log), logf)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/loadsave.py", line 45, in dump
    pickle.dump(o, f, pickle.HIGHEST_PROTOCOL)
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 1370, in dump
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 224, in dump
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 548, in save_tuple
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 331, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 419, in save_reduce
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 649, in save_dict
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 681, in _batch_setitems
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 600, in save_list
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 633, in _batch_appends
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 331, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 419, in save_reduce
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 649, in save_dict
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 681, in _batch_setitems
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 649, in save_dict
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 681, in _batch_setitems
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 649, in save_dict
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 681, in _batch_setitems
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 753, in save_global
PicklingError: Can't pickle <function pickNotebook at 0x1055c8488>: it's not the same object as store.pickNotebook

Darwin-14.4.0-x86_64-i386-64bit
Ren'Py 6.99.11.1749
A Blastastic Love Story 1.0
Last edited by needchocolatenow on Thu Sep 07, 2017 2:11 pm, edited 1 time in total.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Can't Pickle error upon trying to save

#2 Post by Divona » Wed Sep 06, 2017 10:48 pm

Completed:
Image

needchocolatenow
Newbie
Posts: 10
Joined: Sun Aug 27, 2017 12:44 pm
Tumblr: https://chocodevs.tumblr.com/
itch: chocomarimo.
Contact:

Re: Can't Pickle error upon trying to save

#3 Post by needchocolatenow » Wed Sep 06, 2017 10:56 pm

Yes, I have seen that thread; I haven't imported anything so I'm not sure if my solution would be the same as the OP of that thread. I used define config.use_cpickle = False to get the above tracelog. I tried define config.save_dump = True and I got the following code, which didn't tell me much. Maybe this tracelog is more useful for others?

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00gamemenu.rpy", line 173, in script
    $ ui.interact()
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
  File "renpy/common/00action_file.rpy", line 357, in __call__
    renpy.save(fn, extra_info=save_name)
IOError: [Errno 13] Permission denied: 'save_dump.txt'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/00gamemenu.rpy", line 173, in script
    $ ui.interact()
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/ast.py", line 805, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/python.py", line 1641, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/ui.py", line 278, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/core.py", line 2496, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/core.py", line 3172, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 928, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/transition.py", line 45, in event
    return self.new_widget.event(ev, x, y, st) # E1101
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 928, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 928, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/screen.py", line 646, in event
    rv = self.child.event(ev, x, y, st)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 928, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 204, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 928, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 204, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 928, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/layout.py", line 204, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/behavior.py", line 868, in event
    return handle_click(self.clicked)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/behavior.py", line 803, in handle_click
    rv = run(action)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/display/behavior.py", line 302, in run
    return action(*args, **kwargs)
  File "renpy/common/00action_file.rpy", line 357, in __call__
    renpy.save(fn, extra_info=save_name)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/loadsave.py", line 278, in save
    save_dump(roots, renpy.game.log)
  File "/Users/mlau1137/Desktop/renpy-6.99.11-sdk/renpy/loadsave.py", line 175, in save_dump
    f = file("save_dump.txt", "w")
IOError: [Errno 13] Permission denied: 'save_dump.txt'

Darwin-14.4.0-x86_64-i386-64bit
Ren'Py 6.99.11.1749
A Blastastic Love Story 1.0

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Can't Pickle error upon trying to save

#4 Post by Divona » Wed Sep 06, 2017 11:04 pm

Code: Select all

IOError: [Errno 13] Permission denied: 'save_dump.txt'
That simply means Windows is refused to create and save a file name 'save_dump.txt' to the drive. I wonder if run Ren'Py again as administrator would help? It could be the same problem why you can't save in Ren'Py game also.

EDIT: Oh, Darwin-14.4... is that Linux dist or a Mac? It's all simply come down to OS refused to create a file because of permission problem still. Wondering how to bypass that on a Mac... sudo and Terminal?

EDIT2: You can try run the game on Windows and see if it still giving the same error when save. If it doesn't, that really point to Mac OS permission issue.

EDIT3: Does create a new project and try to save in there working?
Completed:
Image

needchocolatenow
Newbie
Posts: 10
Joined: Sun Aug 27, 2017 12:44 pm
Tumblr: https://chocodevs.tumblr.com/
itch: chocomarimo.
Contact:

Re: Can't Pickle error upon trying to save

#5 Post by needchocolatenow » Wed Sep 06, 2017 11:38 pm

I'm on a Mac and I should have permissions for saving. I created a new project and saved as you said to try, and the new project saved and loaded correctly.

[edit] Tried the game file I was working on in Windows; I get the error in the first post when I tried to save.

User avatar
Divona
Miko-Class Veteran
Posts: 678
Joined: Sun Jun 05, 2016 8:29 pm
Completed: The Falconers: Moonlight
Organization: Bionic Penguin
itch: bionicpenguin
Contact:

Re: Can't Pickle error upon trying to save

#6 Post by Divona » Thu Sep 07, 2017 12:00 am

It wouldn't be OS permission then... next, I would try to replicate the error by add things in step by step to the new project until the error appears. Then I would know exactly what the last thing I did cause the error in the first place.
Completed:
Image

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Can't Pickle error upon trying to save

#7 Post by PyTom » Thu Sep 07, 2017 1:01 am

How do you define pickNotebook? You could get this error if it's defined in a python block rather than an init python block.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

needchocolatenow
Newbie
Posts: 10
Joined: Sun Aug 27, 2017 12:44 pm
Tumblr: https://chocodevs.tumblr.com/
itch: chocomarimo.
Contact:

Re: Can't Pickle error upon trying to save

#8 Post by needchocolatenow » Thu Sep 07, 2017 1:23 pm

This is how I defined it in the script file.

Code: Select all

init python:
    def pickPencil():
        return pickPencil
    def pickNotebook():
        return pickNotebook

label start:
    default pickPencil = False
    default pickNotebook = False

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Can't Pickle error upon trying to save

#9 Post by PyTom » Thu Sep 07, 2017 2:03 pm

Functions and variables share a namespace in Python. So when you have them sharing names like this, you're not going to get what you want.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

needchocolatenow
Newbie
Posts: 10
Joined: Sun Aug 27, 2017 12:44 pm
Tumblr: https://chocodevs.tumblr.com/
itch: chocomarimo.
Contact:

Re: Can't Pickle error upon trying to save

#10 Post by needchocolatenow » Thu Sep 07, 2017 2:11 pm

Thank you, Tom! That's what did it. I'll be sure to keep my variables and functions separate from now on.

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot]