Skip to content

Can't pickle local object 'calcInteractionsMultipleFrames.<locals>.analyseFrame' #2192

Open

Description

@houyaxuan634-coder

I am trying to use insty in Prody 2.6.1
I provide an ensemble pdb file with 40 structures (with hydrogens)
the command is
calcHydrogenBondsTrajectory(atoms)
I get the following error

AttributeError Traceback (most recent call last)
Cell In[6], line 1
----> 1 calcHydrogenBondsTrajectory(atoms)

File ~\anaconda3\envs\prody_env\Lib\site-packages\prody\proteins\interactions.py:1929, in calcHydrogenBondsTrajectory(atoms, trajectory, **kwargs)
1887 def calcHydrogenBondsTrajectory(atoms, trajectory=None, **kwargs):
1888 """Compute hydrogen bonds for DCD trajectory or multi-model PDB using default parameters.
1889
1890 :arg atoms: an Atomic object from which residues are selected
(...) 1926 If we want to study chain-chain interactions:
1927 selection='chain A', selection2='chain B' """
-> 1929 return calcInteractionsMultipleFrames(atoms, 'HBs', trajectory, **kwargs)

File ~\anaconda3\envs\prody_env\Lib\site-packages\prody\proteins\interactions.py:1817, in calcInteractionsMultipleFrames(atoms, interaction_type, trajectory, **kwargs)
1815 for _ in range(max_proc):
1816 p = mp.Process(target=analyseFrame, args=(i, interactions_all))
-> 1817 p.start()
1818 processes.append(p)
1820 i += 1

File ~\anaconda3\envs\prody_env\Lib\multiprocessing\process.py:121, in BaseProcess.start(self)
118 assert not _current_process._config.get('daemon'),
119 'daemonic processes are not allowed to have children'
120 _cleanup()
--> 121 self._popen = self._Popen(self)
122 self._sentinel = self._popen.sentinel
123 # Avoid a refcycle if the target function holds an indirect
124 # reference to the process object (see bpo-30775)

File ~\anaconda3\envs\prody_env\Lib\multiprocessing\context.py:224, in Process._Popen(process_obj)
222 @staticmethod
223 def _Popen(process_obj):
--> 224 return _default_context.get_context().Process._Popen(process_obj)

File ~\anaconda3\envs\prody_env\Lib\multiprocessing\context.py:336, in SpawnProcess._Popen(process_obj)
333 @staticmethod
334 def _Popen(process_obj):
335 from .popen_spawn_win32 import Popen
--> 336 return Popen(process_obj)

File ~\anaconda3\envs\prody_env\Lib\multiprocessing\popen_spawn_win32.py:95, in Popen.init(self, process_obj)
93 try:
94 reduction.dump(prep_data, to_child)
---> 95 reduction.dump(process_obj, to_child)
96 finally:
97 set_spawning_popen(None)

File ~\anaconda3\envs\prody_env\Lib\multiprocessing\reduction.py:60, in dump(obj, file, protocol)
58 def dump(obj, file, protocol=None):
59 '''Replacement for pickle.dump() using ForkingPickler.'''
---> 60 ForkingPickler(file, protocol).dump(obj)

AttributeError: Can't pickle local object 'calcInteractionsMultipleFrames..analyseFrame'

can you please help?
Luke

Activity

  1. AnthonyBogetti commented on Dec 8, 2025

    @AnthonyBogetti
    Member

    Hello @houyaxuan634-coder, would you also be able to share the full code you are using? Feel free to share the pdb file as well, but if you don't want to I can substitute my own test file. This will help me reproduce the error and come up with a solution quickly.

  2. houyaxuan634-coder commented on Dec 8, 2025

    @houyaxuan634-coder
    Author

    Yeah sure
    I was trying to launch the Ensemble PDB analysis function in Insty. So I read through the tutorial on insty (This is the link to the tutorial: http://www.bahargroup.org/prody/tutorials/insty_tutorial/ensemblePDB.html)
    I used the PDB I have for the protein which contains 40 model in one PDB, then I follow the tutorial but that error came up when I attempt to run it.
    Then I thought the error may be have something to do with my PDB file so I used the exact same command on the tutorial (the 2k39 model) but it does not work as well

    The following is my code when I tried to use the 2k39 model
    import prody
    from prody.proteins.interactions import calcHydrogenBondsTrajectory
    from prody import parsePDB
    atoms = parsePDB('2k39')
    calcHydrogenBondsTrajectory(atoms)

    the output is

    AttributeError Traceback (most recent call last)
    Cell In[5], line 1
    ----> 1 calcHydrogenBondsTrajectory(atoms)

    File ~\anaconda3\envs\prody_env\Lib\site-packages\prody\proteins\interactions.py:1929, in calcHydrogenBondsTrajectory(atoms, trajectory, **kwargs)
    1887 def calcHydrogenBondsTrajectory(atoms, trajectory=None, **kwargs):
    1888 """Compute hydrogen bonds for DCD trajectory or multi-model PDB using default parameters.
    1889
    1890 :arg atoms: an Atomic object from which residues are selected
    (...) 1926 If we want to study chain-chain interactions:
    1927 selection='chain A', selection2='chain B' """
    -> 1929 return calcInteractionsMultipleFrames(atoms, 'HBs', trajectory, **kwargs)

    File ~\anaconda3\envs\prody_env\Lib\site-packages\prody\proteins\interactions.py:1817, in calcInteractionsMultipleFrames(atoms, interaction_type, trajectory, **kwargs)
    1815 for _ in range(max_proc):
    1816 p = mp.Process(target=analyseFrame, args=(i, interactions_all))
    -> 1817 p.start()
    1818 processes.append(p)
    1820 i += 1

    File ~\anaconda3\envs\prody_env\Lib\multiprocessing\process.py:121, in BaseProcess.start(self)
    118 assert not _current_process._config.get('daemon'),
    119 'daemonic processes are not allowed to have children'
    120 _cleanup()
    --> 121 self._popen = self._Popen(self)
    122 self._sentinel = self._popen.sentinel
    123 # Avoid a refcycle if the target function holds an indirect
    124 # reference to the process object (see bpo-30775)

    File ~\anaconda3\envs\prody_env\Lib\multiprocessing\context.py:224, in Process._Popen(process_obj)
    222 @staticmethod
    223 def _Popen(process_obj):
    --> 224 return _default_context.get_context().Process._Popen(process_obj)

    File ~\anaconda3\envs\prody_env\Lib\multiprocessing\context.py:336, in SpawnProcess._Popen(process_obj)
    333 @staticmethod
    334 def _Popen(process_obj):
    335 from .popen_spawn_win32 import Popen
    --> 336 return Popen(process_obj)

    File ~\anaconda3\envs\prody_env\Lib\multiprocessing\popen_spawn_win32.py:95, in Popen.init(self, process_obj)
    93 try:
    94 reduction.dump(prep_data, to_child)
    ---> 95 reduction.dump(process_obj, to_child)
    96 finally:
    97 set_spawning_popen(None)

    File ~\anaconda3\envs\prody_env\Lib\multiprocessing\reduction.py:60, in dump(obj, file, protocol)
    58 def dump(obj, file, protocol=None):
    59 '''Replacement for pickle.dump() using ForkingPickler.'''
    ---> 60 ForkingPickler(file, protocol).dump(obj)

    AttributeError: Can't pickle local object 'calcInteractionsMultipleFrames..analyseFrame'

    Thank you very much for your reply

  3. houyaxuan634-coder commented on Dec 11, 2025

    @houyaxuan634-coder
    Author

    I forgot to mention
    Prody version I used is 2.6.1
    NumPy version is 1.23.5
    scipy is 1.15.3 matplotlib is 3.10.6
    I am not sure does the version affect some of the function of prody?

  4. stoneandbone commented on Mar 3, 2026

    @stoneandbone
    Contributor

    Hi, you may be able to run this by running:
    import multiprocessing as mp
    mp.set_start_method("fork", force=True)
    Before you perform calcHydrogenBondsTrajectory(atoms).

  5. jamesmkrieger commented on Jul 13, 2026

    @jamesmkrieger
    Contributor

    What Python version and multiprocessing version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions