This notebook serves to document an error when reloading the owlready2 module due to the access to nonexisting dictionary entries.
import importlib
import owlready2 as owl2
# this works:
# createing dummy values for some dictionary entries
owl2.owl_world._props["Property"] = None
owl2.owl_world._props["ObjectProperty"] = None
owl2.owl_world._props["DatatypeProperty"] = None
owl2.owl_world._props["FunctionalProperty"] = None
owl2.owl_world._props["InverseFunctionalProperty"] = None
owl2.owl_world._props["TransitiveProperty"] = None
owl2.owl_world._props["SymmetricProperty"] = None
owl2.owl_world._props["AsymmetricProperty"] = None
owl2.owl_world._props["ReflexiveProperty"] = None
owl2.owl_world._props["IrreflexiveProperty"] = None
owl2.owl_world._props["AnnotationProperty"] = None
importlib.reload(owl2)
<module 'owlready2' from '/media/workcard/workstickdir/RST/expertise_system/ontologie_experimente/owlready2_repo_parent/owlready2/__init__.py'>
# this works not (KeyError):
importlib.reload(owl2)
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) Input In [3], in <module> 1 # this works not (key error): ----> 2 importlib.reload(owl2) File ~/miniconda3/envs/base38/lib/python3.8/importlib/__init__.py:169, in reload(module) 167 if spec is None: 168 raise ModuleNotFoundError(f"spec not found for the module {name!r}", name=name) --> 169 _bootstrap._exec(spec, module) 170 # The module may have replaced itself in sys.modules! 171 return sys.modules[name] File <frozen importlib._bootstrap>:604, in _exec(spec, module) File <frozen importlib._bootstrap_external>:783, in exec_module(self, module) File <frozen importlib._bootstrap>:219, in _call_with_frames_removed(f, *args, **kwds) File /media/workcard/workstickdir/RST/expertise_system/ontologie_experimente/owlready2_repo_parent/owlready2/__init__.py:117, in <module> 114 LOADING.__exit__() 116 # Not real property --> 117 del owl_world._props["Property"] 118 del owl_world._props["ObjectProperty"] 119 del owl_world._props["DatatypeProperty"] KeyError: 'Property'