Open acpirience opened 9 months ago
This is not a bug nor something I can avoid. Loguru needs to import and use the token
module which exists in the Python standard libraries. When Python resolves imports, your custom token
module is conflicting with the built-in one, and Python ends up importing the wrong module for some reason (it depends on import paths resolution order).
Hello, I don't know it's a know problem or not and if you''l think it's a real bug (or that it is not specific to loguru)
To summarize, when you have a token.py in your project you get an ImportError when importing loguru.
Steps to reproduce:
main.py
file containing the following content:logger.info("Test")
$ python main.py 2024-02-08 17:12:31.966 | INFO | main::3 - Test
$ python main.py Traceback (most recent call last): File "D:\repo\test\main.py", line 1, in
from loguru import logger
File "D:\dev\python310\Lib\site-packages\loguru__init.py", line 10, in
from ._logger import Core as _Core
File "D:\dev\python310\Lib\site-packages\loguru_logger.py", line 88, in
import logging
File "D:\dev\python310\Lib\logging\ init__.py", line 26, in
import sys, os, time, io, re, traceback, warnings, weakref, collections.abc
File "D:\dev\python310\Lib\traceback.py", line 5, in
import linecache
File "D:\dev\python310\Lib\linecache.py", line 11, in
import tokenize
File "D:\dev\python310\Lib\tokenize.py", line 36, in
from token import EXACT_TOKEN_TYPES
ImportError: cannot import name 'EXACT_TOKEN_TYPES' from 'token' (D:\repo\test\token.py)