Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run backend error #386

Open
Hj419522039 opened this issue Aug 8, 2024 · 2 comments
Open

run backend error #386

Hj419522039 opened this issue Aug 8, 2024 · 2 comments

Comments

@Hj419522039
Copy link

poetry run uvicorn main:app --reload --port 7001
INFO: Will watch for changes in these directories: ['/Users/zhuhongji/Documents/workspace/screenshot-to-code/backend']
INFO: Uvicorn running on http://127.0.0.1:7001 (Press CTRL+C to quit)
INFO: Started reloader process [12100] using StatReload
Process SpawnProcess-1:
Traceback (most recent call last):
File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/uvicorn/_subprocess.py", line 76, in subprocess_started
target(sockets=sockets)
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/uvicorn/server.py", line 61, in run
return asyncio.run(self.serve(sockets=sockets))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/uvicorn/server.py", line 68, in serve
config.load()
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/uvicorn/config.py", line 467, in load
self.loaded_app = import_from_string(self.app)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/uvicorn/importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in find_and_load_unlocked
File "", line 935, in load_unlocked
File "", line 995, in exec_module
File "", line 488, in call_with_frames_removed
File "/Users/zhuhongji/Documents/workspace/screenshot-to-code/backend/main.py", line 7, in
from fastapi import FastAPI
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/fastapi/init.py", line 7, in
from .applications import FastAPI as FastAPI
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/fastapi/applications.py", line 16, in
from fastapi import routing
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/fastapi/routing.py", line 24, in
from fastapi.dependencies.models import Dependant
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/fastapi/dependencies/models.py", line 3, in
from fastapi.security.base import SecurityBase
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/fastapi/security/init.py", line 1, in
from .api_key import APIKeyCookie as APIKeyCookie
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/fastapi/security/api_key.py", line 3, in
from fastapi.openapi.models import APIKey, APIKeyIn
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/fastapi/openapi/models.py", line 103, in
class Schema(BaseModel):
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/pydantic/main.py", line 286, in new
cls.try_update_forward_refs()
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/pydantic/main.py", line 807, in try_update_forward_refs
update_model_forward_refs(cls, cls.fields.values(), cls.config.json_encoders, localns, (NameError,))
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/pydantic/typing.py", line 554, in update_model_forward_refs
update_field_forward_refs(f, globalns=globalns, localns=localns)
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/pydantic/typing.py", line 520, in update_field_forward_refs
field.type
= evaluate_forwardref(field.type
, globalns, localns or None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/zhuhongji/Library/Caches/pypoetry/virtualenvs/backend-fXnATXJ6-py3.12/lib/python3.12/site-packages/pydantic/typing.py", line 66, in evaluate_forwardref
return cast(Any, type
)._evaluate(globalns, localns, set())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'

@yalinyy
Copy link

yalinyy commented Aug 8, 2024

I also encountered the same issue.

@abi
Copy link
Owner

abi commented Aug 8, 2024

Try downgrading your Python to python:3.12.3 or lower. The new version of Pydantic has some issues with the later Python versions.

Let me know if that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants