s3rius / FastAPI-template

Feature rich robust FastAPI template.
MIT License
2.02k stars 174 forks source link

partially initialized module 'asyncio' has no attribute 'get_running_loop' #208

Closed SyedDaniyalHassan closed 4 months ago

SyedDaniyalHassan commented 7 months ago

I am facing the error, when load the project first time. Here is the stack trace: `C:\Users\daniyal.hassan\AppData\Local\pypoetry\Cache\virtualenvs\basic-app-30r8rR07-py3.10\Scripts\python.exe D:\NewPC\Playground\python\FastAPI\basic_app\basic_app Traceback (most recent call last): File "C:\Users\daniyal.hassan\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\daniyal.hassan\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "D:\NewPC\Playground\python\FastAPI\basic_app\basic_app__main.py", line 1, in import uvicorn File "C:\Users\daniyal.hassan\AppData\Local\pypoetry\Cache\virtualenvs\basic-app-30r8rR07-py3.10\lib\site-packages\uvicorn__init.py", line 1, in from uvicorn.config import Config File "C:\Users\daniyal.hassan\AppData\Local\pypoetry\Cache\virtualenvs\basic-app-30r8rR07-py3.10\lib\site-packages\uvicorn\config.py", line 1, in import asyncio File "C:\Users\daniyal.hassan\AppData\Local\Programs\Python\Python310\lib\asyncio\init.py", line 8, in from .base_events import * File "C:\Users\daniyal.hassan\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 18, in import concurrent.futures File "C:\Users\daniyal.hassan\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\init__.py", line 8, in from concurrent.futures._base import (FIRST_COMPLETED, File "C:\Users\daniyal.hassan\AppData\Local\Programs\Python\Python310\lib\concurrent\futures_base.py", line 7, in import logging File "D:\NewPC\Playground\python\FastAPI\basic_app\basic_app\logging.py", line 5, in from loguru import logger File "C:\Users\daniyal.hassan\AppData\Local\pypoetry\Cache\virtualenvs\basic-app-30r8rR07-py3.10\lib\site-packages\loguru\init__.py", line 10, in from ._logger import Core as _Core File "C:\Users\daniyal.hassan\AppData\Local\pypoetry\Cache\virtualenvs\basic-app-30r8rR07-py3.10\lib\site-packages\loguru_logger.py", line 99, in from . import _asyncio_loop, _colorama, _defaults, _filters File "C:\Users\daniyal.hassan\AppData\Local\pypoetry\Cache\virtualenvs\basic-app-30r8rR07-py3.10\lib\site-packages\loguru_asyncio_loop.py", line 27, in get_task_loop, get_running_loop = load_loop_functions() File "C:\Users\daniyal.hassan\AppData\Local\pypoetry\Cache\virtualenvs\basic-app-30r8rR07-py3.10\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)

Process finished with exit code 1 `

and here is generated pyproject.toml file:

`[tool.poetry] name = "basic_app" version = "0.1.0" description = "" authors = [

] maintainers = [

] readme = "README.md"

[tool.poetry.dependencies] python = "^3.9" fastapi = "^0.100.0" uvicorn = { version = "^0.22.0", extras = ["standard"] } fastapi-users = "^12.1.2" httpx-oauth = "^0.10.2" fastapi-users-db-sqlalchemy = "^6.0.1" pydantic = "^2" pydantic-settings = "^2" yarl = "^1.9.2" ujson = "^5.8.0" SQLAlchemy = {version = "^2.0.18", extras = ["asyncio"]} aiosqlite = "^0.19.0" httptools = "^0.6.0" loguru = "^0.7.0"

[tool.poetry.dev-dependencies] pytest = "^7.2.1" flake8 = "~4.0.1" mypy = "^1.1.1" isort = "^5.11.4" pre-commit = "^3.0.1" wemake-python-styleguide = "^0.17.0" black = "^22.12.0" autoflake = "^1.6.1" pytest-cov = "^4.0.0" anyio = "^3.6.2" pytest-env = "^0.8.1" httpx = "^0.23.3"

[tool.isort] profile = "black" multi_line_output = 3 src_paths = ["basic_app",]

[tool.mypy] strict = true ignore_missing_imports = true allow_subclassing_any = true allow_untyped_calls = true pretty = true show_error_codes = true implicit_reexport = true allow_untyped_decorators = true warn_unused_ignores = false warn_return_any = false namespace_packages = true

[tool.pytest.ini_options] filterwarnings = [ "error", "ignore::DeprecationWarning", "ignore:.unclosed.:ResourceWarning", ] env = [ "BASIC_APP_ENVIRONMENT=pytest", "BASIC_APP_DB_FILE=test_db.sqlite3", ]

[fastapi-template.options] project_name = "basic_app" api_type = "rest" enable_redis = "None" enable_rmq = "None" ci_type = "github" enable_migrations = "None" enable_taskiq = "None" enable_kube = "True" kube_name = "basic-app" 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 = "None" add_users = "True" cookie_auth = "None" jwt_auth = "True"

[build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" `

dualmacops commented 6 months ago

rename the logging.py file to something else

s3rius commented 4 months ago

Logging was renamed, should not be an issue anymore.