abi / screenshot-to-code

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
https://screenshottocode.com
MIT License
56.07k stars 6.88k forks source link

run backend error #386

Open Hj419522039 opened 1 month ago

Hj419522039 commented 1 month ago

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/python@3.12/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/python@3.12/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/python@3.12/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/python@3.12/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/python@3.12/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/python@3.12/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_forwardrefs field.type = evaluateforwardref(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 evaluateforwardref return cast(Any, type)._evaluate(globalns, localns, set()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'

yalinyy commented 1 month ago

I also encountered the same issue.

abi commented 1 month ago

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.