You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into an exception in loguru/_better_exceptions.py::ExceptionFormatter._get_lib_dirs() when site.USER_SITE is used without checking for None. This is happening when using the Windows embedded Python distribution which, by default, does not initialize the site module on startup.
From the documentation for the builtin site module regarding site.USER_SITE:
Path to the user site-packages for the running Python. Can be None if getusersitepackages() hasn’t been called yet.
The issue can be reproduced by eliminating the site execution on startup using the -s and -S flags. In the following example, I created a virtual environment on my Linux box and installed loguru using pip.
$ python3 -m venv venv
$ . venv/bin/activate
(venv) $ pip install loguru
...
(venv) $ PYTHONPATH='venv/lib/python3.7/site-packages' python -sS
Python 3.7.3 (default, Jun 24 2019, 04:54:02)
[GCC 9.1.0] on linux
>>> import loguru
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "venv/lib/python3.7/site-packages/loguru/__init__.py", line 19, in <module>
logger.add(_sys.stderr)
File "venv/lib/python3.7/site-packages/loguru/_logger.py", line 821, in add
hidden_frames_filename=self.catch.__code__.co_filename,
File "venv/lib/python3.7/site-packages/loguru/_better_exceptions.py", line 133, in __init__
self._lib_dirs = self._get_lib_dirs()
File "venv/lib/python3.7/site-packages/loguru/_better_exceptions.py", line 161, in _get_lib_dirs
return [os.path.abspath(d) + os.sep for d in lib_dirs]
File "venv/lib/python3.7/site-packages/loguru/_better_exceptions.py", line 161, in <listcomp>
return [os.path.abspath(d) + os.sep for d in lib_dirs]
File "/usr/lib/python3.7/posixpath.py", line 378, in abspath
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType
>>>
I'm currently working around the issue by ensuring that site is executed on startup.
The text was updated successfully, but these errors were encountered:
I'm running into an exception in
loguru/_better_exceptions.py::ExceptionFormatter._get_lib_dirs()
whensite.USER_SITE
is used without checking forNone
. This is happening when using the Windows embedded Python distribution which, by default, does not initialize the site module on startup.From the documentation for the builtin site module regarding
site.USER_SITE
:The issue can be reproduced by eliminating the site execution on startup using the -s and -S flags. In the following example, I created a virtual environment on my Linux box and installed loguru using pip.
I'm currently working around the issue by ensuring that site is executed on startup.
The text was updated successfully, but these errors were encountered: