Open vikramsubramanian opened 3 months ago
KeyError: 'platstdlib'
when using Loguru with PyPy on OSX.'platstdlib'
key in the paths dictionary returned by sysconfig.get_paths()
or sysconfig.get_path()
.' platstdlib'
suggests that there might be an issue with extra whitespace in the key being used to access the dictionary.To resolve the issue:
_get_lib_dirs
method in loguru/_better_exceptions.py
._get_lib_dirs
to strip leading and trailing whitespace from the keys before using them to access the paths dictionary.@staticmethod
def _get_lib_dirs():
schemes = sysconfig.get_scheme_names()
names = ["stdlib", "platstdlib", "platlib", "purelib"]
paths = {sysconfig.get_path(name.strip(), scheme) for scheme in schemes for name in names}
return [os.path.abspath(path).lower() + os.sep for path in paths if path in sys.path]
name.strip()
is used to remove any leading or trailing whitespace from the key names.
I have a pypy installed with homebrew on OSX 12.5.1
I'm getting the following error while trying to import loguru:
I have been able to localize it to concrete key
osx_framework_user
:This is because
platstdlib
corresponding key has leading spaces for some reason:)