Skip to content

Loguru startup error #191

Open
Open

Description

@RoyalGoose

After initializing blank project with loguru as logger poetry run python -m project_name it gives an error:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\Documents\Projects\project_name\project_name\__main__.py", line 4, in <module>
    import uvicorn
  File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\project-name-uwC7DCiD-py3.11\Lib\site-packages\uvicorn\__init__.py", line 1, in <module>
    from uvicorn.config import Config
  File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\project-name-uwC7DCiD-py3.11\Lib\site-packages\uvicorn\config.py", line 1, in <module>
    import asyncio
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\asyncio\__init__.py", line 8, in <module>
    from .base_events import *
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 18, in <module>
    import concurrent.futures
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\__init__.py", line 8, in <module>
    from concurrent.futures._base import (FIRST_COMPLETED,
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\_base.py", line 7, in <module>
    import logging
  File "C:\Users\User\Documents\Projects\project_name\project_name\logging.py", line 5, in <module>
    from loguru import logger
  File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\project-name-uwC7DCiD-py3.11\Lib\site-packages\loguru\__init__.py", line 10, in <module>
    from ._logger import Core as _Core
  File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\project-name-uwC7DCiD-py3.11\Lib\site-packages\loguru\_logger.py", line 99, in <module>
    from . import _asyncio_loop, _colorama, _defaults, _filters
  File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\project-name-uwC7DCiD-py3.11\Lib\site-packages\loguru\_asyncio_loop.py", line 27, in <module>
    get_task_loop, get_running_loop = load_loop_functions()
                                      ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\pypoetry\Cache\virtualenvs\project-name-uwC7DCiD-py3.11\Lib\site-packages\loguru\_asyncio_loop.py", line 11, in load_loop_functions
    get_running_loop = asyncio.get_running_loop
                       ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: partially initialized module 'asyncio' has no attribute 'get_running_loop' (most likely due to a circular import)

After renaming file project_name/logging.py to project_name/log.py it works

Activity

  1. s3rius commented on Oct 2, 2023

    @s3rius
    Owner

    🤔 🤔 🤔 🤔

    How could possible asyncio be partially initialized? Can you please give me all parameters you were using from pyproject.toml? Section called [fastapi-template.options].

  2. s3rius commented on Oct 2, 2023

    @s3rius
    Owner

    Do you have a module called asyncio in your codebase?

  3. s3rius commented on Oct 2, 2023

    @s3rius
    Owner

    Or any name that can be the same with some modules from the sandard library?

  4. RoyalGoose commented on Oct 2, 2023

    @RoyalGoose
    Author

    @s3rius

    🤔 🤔 🤔 🤔

    How could possible asyncio be partially initialized? Can you please give me all parameters you were using from pyproject.toml? Section called [fastapi-template.options].

    [fastapi-template.options]
    project_name = "test_template"
    api_type = "rest"
    enable_redis = "None"
    enable_rmq = "None"
    ci_type = "gitlab_ci"
    enable_migrations = "True"
    enable_taskiq = "True"
    enable_kube = "True"
    kube_name = "test-template"
    enable_routers = "True"
    enable_kafka = "True"
    enable_loguru = "True"
    traefik_labels = "True"
    add_dummy = "True"
    orm = "ormar"
    self_hosted_swagger = "None"
    prometheus_enabled = "True"
    sentry_enabled = "True"
    otlp_enabled = "True"
    pydanticv1 = "True"
    gunicorn = "None"
    add_users = "None"
    cookie_auth = "None"
    jwt_auth = "None"

    Do you have a module called asyncio in your codebase?

    Only original asyncio library

    Or any name that can be the same with some modules from the sandard library?

    No

  5. vaavaa commented on Oct 13, 2023

    @vaavaa

    I have the same for me.

    [fastapi-template.options]
    project_name = "img_store"
    api_type = "rest"
    enable_redis = "None"
    enable_rmq = "None"
    ci_type = "none"
    enable_migrations = "True"
    enable_taskiq = "None"
    enable_kube = "None"
    kube_name = "img-store"
    enable_routers = "True"
    enable_kafka = "None"
    enable_loguru = "True"
    traefik_labels = "None"
    add_dummy = "True"
    orm = "sqlalchemy"
    self_hosted_swagger = "None"
    prometheus_enabled = "None"
    sentry_enabled = "None"
    otlp_enabled = "None"
    pydanticv1 = "None"
    gunicorn = "True"
    add_users = "None"
    cookie_auth = "None"
    jwt_auth = "None"

  6. s3rius commented on Nov 20, 2023

    @s3rius
    Owner

    Guess I know the solution for that. Thanks for finding it out.

  7. mxft commented on Mar 20, 2024

    @mxft

    Guess I know the solution for that. Thanks for finding it out.

    And what's the solution? The problem is still present

  8. mxft commented on Mar 20, 2024

    @mxft

    Fixed it. Just rename logging.py to _logging.py or whatever you want it to be

  9. s3rius commented on Mar 20, 2024

    @s3rius
    Owner

    I couldn't find the solution previously. @mxft, that's lit! I'll fix it later.

  10. ken-kuro commented on Apr 1, 2024

    @ken-kuro

    Fixed it. Just rename logging.py to _logging.py or whatever you want it to be

    Rename does work, but could you please explain what's the bug and how did you come up with that solution ?

  11. mxft commented on Apr 9, 2024

    @mxft

    Rename does work, but could you please explain what's the bug and how did you come up with that solution ?

    I didn't dive much into it, but I just though that it has something to do with from logging import ... mixing up in different places, so I just tried to rename the local module since it has the same name and may interfere in some way. It did the job, as you can see.

    @s3rius can we expect the repository to be updated in near future? It pretty much seems abandoned at this point, but fixing major problems and bumping some package versions won't take much of your time

  12. ken-kuro commented on Apr 10, 2024

    @ken-kuro

    I see, thanks for your reply

  13. s3rius commented on Jul 12, 2024

    @s3rius
    Owner

    The issue was resolved, the logging module was renamed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions