Can't pickle <type 'function'>

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
LabaroDD
Regular
Posts: 34
Joined: Thu Apr 14, 2016 7:47 am
Contact:

Can't pickle <type 'function'>

#1 Post by LabaroDD » Mon Feb 13, 2017 1:53 pm

Hello everyone...
Here is the error I'm trying to solve for the last hour. I will be very happy if someone could help me...

I got it when I reload a project:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00keymap.rpy", line 396, in script
    python hide:
  File "renpy/common/00keymap.rpy", line 411, in <module>
    renpy.save("_reload-1", "reload save game")
PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed

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

Full traceback:
  File "renpy/common/00keymap.rpy", line 396, in script
    python hide:
  File "D:\Soft\renpy-6.99.8-sdk\renpy\ast.py", line 814, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\python.py", line 1715, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/00keymap.rpy", line 411, in <module>
    renpy.save("_reload-1", "reload save game")
  File "D:\Soft\renpy-6.99.8-sdk\renpy\loadsave.py", line 286, in save
    dump((roots, renpy.game.log), logf)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\loadsave.py", line 45, in dump
    cPickle.dump(o, f, cPickle.HIGHEST_PROTOCOL)
PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed
and I got another error, I tried to save a game:

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 <type 'function'>: attribute lookup __builtin__.function failed

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

Full traceback:
  File "renpy/common/00gamemenu.rpy", line 173, in script
    $ ui.interact()
  File "D:\Soft\renpy-6.99.8-sdk\renpy\ast.py", line 814, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\python.py", line 1715, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
  File "D:\Soft\renpy-6.99.8-sdk\renpy\ui.py", line 285, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\core.py", line 2507, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\core.py", line 3181, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\transition.py", line 45, in event
    return self.new_widget.event(ev, x, y, st)  # E1101
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\screen.py", line 651, in event
    rv = self.child.event(ev, x, y, st)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\layout.py", line 232, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\layout.py", line 232, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\viewport.py", line 303, in event
    rv = super(Viewport, self).event(ev, x, y, st)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\layout.py", line 232, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\behavior.py", line 889, in event
    return handle_click(self.clicked)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\behavior.py", line 824, in handle_click
    rv = run(action)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\display\behavior.py", line 306, in run
    return action(*args, **kwargs)
  File "renpy/common/00action_file.rpy", line 357, in __call__
    renpy.save(fn, extra_info=save_name)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\loadsave.py", line 286, in save
    dump((roots, renpy.game.log), logf)
  File "D:\Soft\renpy-6.99.8-sdk\renpy\loadsave.py", line 45, in dump
    cPickle.dump(o, f, cPickle.HIGHEST_PROTOCOL)
PicklingError: Can't pickle <type 'function'>: attribute lookup __builtin__.function failed

Windows-8-6.2.9200
Ren'Py 6.99.12.3.2123
And cleaning of persistent data doesn't help.

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 <type 'function'>

#2 Post by PyTom » Mon Feb 13, 2017 2:03 pm

set config.save_dump = True, save again, and post the save_dump.txt file so created. That will help to debug what the problem is.
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

LabaroDD
Regular
Posts: 34
Joined: Thu Apr 14, 2016 7:47 am
Contact:

Re: Can't pickle <type 'function'>

#3 Post by LabaroDD » Mon Feb 13, 2017 2:23 pm

PyTom wrote:set config.save_dump = True, save again, and post the save_dump.txt file so created. That will help to debug what the problem is.
Here is it...
https://www.dropbox.com/s/yng4uo67bfyxn ... p.txt?dl=0

LabaroDD
Regular
Posts: 34
Joined: Thu Apr 14, 2016 7:47 am
Contact:

Re: Can't pickle <type 'function'>

#4 Post by LabaroDD » Mon Feb 13, 2017 2:50 pm

I found the problem.
I used two different scripts for parallax, and it conflicted to each other. I deleted one of them (.rpy and .rpyc files) and it works now. I think problem was in variables.

Anyway, thank you very much, PyTom!

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot]