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

Cannot install #3

Closed
AntouanK opened this issue Nov 16, 2023 · 29 comments
Closed

Cannot install #3

AntouanK opened this issue Nov 16, 2023 · 29 comments

Comments

@AntouanK
Copy link

AntouanK commented Nov 16, 2023

Trying to follow your instructions, I went into the backend folder and tried poetry install.

❯ echo "OPENAI_API_KEY=sk-aaa...xxx" > .env
❯ poetry install
Creating virtualenv backend-dR2C48Xf-py3.11 in /home/antouank/.cache/pypoetry/virtualenvs
Installing dependencies from lock file

Package operations: 20 installs, 0 updates, 0 removals

  • Installing certifi (2023.7.22)
  • Installing h11 (0.14.0)
  • Installing idna (3.4)
  • Installing sniffio (1.3.0)
  • Installing anyio (3.7.1)
  • Installing httpcore (1.0.2)
  • Installing typing-extensions (4.8.0)
  • Installing click (8.1.7)
  • Installing distro (1.8.0)
  • Installing httpx (0.25.1)
  • Installing pydantic (1.10.13)
  • Installing soupsieve (2.5)
  • Installing starlette (0.27.0)
  • Installing tqdm (4.66.1)
  • Installing beautifulsoup4 (4.12.2)
  • Installing fastapi (0.95.2)
  • Installing openai (1.2.4)
  • Installing python-dotenv (1.0.0)
  • Installing uvicorn (0.24.0.post1)
  • Installing websockets (12.0)

Installing the current project: backend (0.1.0)
The current project could not be installed: [Errno 2] No such file or directory: '/home/antouank/_REPOS_/screenshot-to-code/backend/README.md'
If you do not want to install the current project use --no-root

I added a README but no difference really.
I also tried running it at the root folder as well, again it throws an error.

❯ touch README.md
❯ poetry install
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: backend (0.1.0)
The current project could not be installed: No file/folder found for package backend
If you do not want to install the current project use --no-root
❯ cd ..
❯ poetry install

Poetry could not find a pyproject.toml file in /home/antouank/_REPOS_/screenshot-to-code or its parents

What am I missing?

( what is "poetry" anyway? )

@vithanhlam
Copy link

you can install pip install poetry

@AntouanK
Copy link
Author

I tried with venv, I get the same result.

❯ poetry install
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: backend (0.1.0)
The current project could not be installed: No file/folder found for package backend
If you do not want to install the current project use --no-root
❯ which poetry
/home/antouank/_REPOS_/screenshot-to-code/backend/venv/bin/poetry

@hudzygg
Copy link

hudzygg commented Nov 16, 2023

Getting the exact same errors here. Hope there is a quick fix for this, really excited to try this out.

@abi
Copy link
Owner

abi commented Nov 16, 2023

pip install poetry should fix these issues. Is anyone having the issue after they do that still? Happy to help debug.

@vfonic
Copy link

vfonic commented Nov 16, 2023

❯ poetry install
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: backend (0.1.0)
The current project could not be installed: [Errno 2] No such file or directory: '/<some-path>/screenshot-to-code/backend/README.md'
If you do not want to install the current project use --no-root

I have installed poetry. It doesn't look like the issue is resolved by installing poetry.

What do you recommend? What can I try? Do you need some logs / command output?

@AntouanK
Copy link
Author

pip install poetry should fix these issues. Is anyone having the issue after they do that still? Happy to help debug.

I have installed poetry in 2 different ways. Made no difference.
If you check the terminal output I posted, the errors are from poetry itself.

@abi
Copy link
Owner

abi commented Nov 16, 2023

@AntouanK sorry i missed that. your logs suggest it's failing because of a missing README file. I removed that, can you pull and retry?

@AntouanK
Copy link
Author

there's no README inside backend.
I added an empty one, and still there was an error ( it's in the logs )

I pulled and tried again. same error

❯ poetry install
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: backend (0.1.0)
The current project could not be installed: No file/folder found for package backend
If you do not want to install the current project use --no-root
❯ ls
total 84K
drwxr-xr-x 3 antouank 4.0K Nov 16 16:03 .
drwxr-xr-x 5 antouank 4.0K Nov 16 16:03 ..
-rw-r--r-- 1 antouank   67 Nov 16 09:21 .env
-rw-r--r-- 1 antouank 2.7K Nov 16 09:19 .gitignore
-rw-r--r-- 1 antouank 3.2K Nov 16 09:19 image_generation.py
-rw-r--r-- 1 antouank  857 Nov 16 09:19 llm.py
-rw-r--r-- 1 antouank 3.0K Nov 16 16:03 main.py
-rw-r--r-- 1 antouank 7.1K Nov 16 09:19 mock.py
-rw-r--r-- 1 antouank  31K Nov 16 09:19 poetry.lock
-rw-r--r-- 1 antouank 2.1K Nov 16 09:19 prompts.py
-rw-r--r-- 1 antouank  397 Nov 16 16:03 pyproject.toml
-rw-r--r-- 1 antouank  788 Nov 16 09:19 utils.py
drwxr-xr-x 5 antouank 4.0K Nov 16 10:10 venv

  ~/_REPOS_/screenshot-to-code/backend on   main ··········································  backend at  16:03:34
❯

have you tried cloning the repo on a new machine and running it?

or maybe try in a python docker container. so you can see what dependencies people need to run it.

thank you.

@abi
Copy link
Owner

abi commented Nov 16, 2023

@AntouanK People have gotten it working on their machine: #6

I tried locally from scratch (but not in a Docker container). Let me look into it.

@AntouanK
Copy link
Author

Yeah, I know that the project works.
It's just the setup step.
Could be that it's people that have a python setup on their machine?
( I'm not a python dev, so maybe I'm missing something python related )

@AntouanK
Copy link
Author

actually I proceed with the last command, and it works fine!

poetry run uvicorn main:app --reload --port 7000

Seems like that error we see is just poetry saying "everything is already installed"?
Not sure.

It seems to work for me.

Thanks for all the help and your work @abi 👍

@vfonic
Copy link

vfonic commented Nov 16, 2023

Ok, this worked for me:

cd backend
mkdir backend # yes, inside backend
mv *.py backend/
poetry install
poetry shell
cd backend # yes, backend/backend
poetry run uvicorn main:app --reload --port 7000

And frontend stuff stays the same.

I suppose an easier solution would be to do mv pyproject.toml ../

@abi
Copy link
Owner

abi commented Nov 16, 2023

@vfonic I can see why that works. Python has weird import mechanisms for the root of the project. Glad it worked for you!

@abi
Copy link
Owner

abi commented Nov 16, 2023

Added some info to the FAQs.

@allyssonallan
Copy link

Ok, this worked for me:

cd backend
mkdir backend # yes, inside backend
mv *.py backend/
poetry install
poetry shell
cd backend # yes, backend/backend
poetry run uvicorn main:app --reload --port 7000

And frontend stuff stays the same.

I suppose an easier solution would be to do mv pyproject.toml ../

Thanks guys. That worked pretty well!

@tuanstereo
Copy link

I want to ask that. If I don't have the open key, can I run this project?. Thank you.

@imsamm04
Copy link

imsamm04 commented Nov 20, 2023

Front end => OK

cd backend => OK
echo "OPENAI_API_KEY=sk-your-key" > .env => OK
poetry install => OK
poetry shell => OK
poetry run uvicorn main:app --reload --port 7001 => Not working

I'm not familiar with Python code, so I tried to follow the instructions, but when I ran the final command to run the backend project, I encountered the following error. How should I fix this issue? Can someone please help me? :(

poetry run uvicorn main:app --reload --port 7001
INFO: Will watch for changes in these directories: ['D:\Practice Projects\screenshot-to-code\backend']
INFO: Uvicorn running on http://127.0.0.1:7001 (Press CTRL+C to quit)
INFO: Started reloader process [16448] using StatReload
Process SpawnProcess-1:
Traceback (most recent call last):
File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 314, in _bootstrap
self.run()
File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn_subprocess.py", line 76, in subprocess_started
target(sockets=sockets)
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\server.py", line 61, in run
return asyncio.run(self.serve(sockets=sockets))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
return self.loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\server.py", line 68, in serve
config.load()
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\config.py", line 467, in load
self.loaded_app = import_from_string(self.app)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\importlib_init
.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1381, in _gcd_import
File "", line 1354, in _find_and_load
File "", line 1325, in _find_and_load_unlocked
File "", line 929, in _load_unlocked
File "", line 994, in exec_module
File "", line 488, in _call_with_frames_removed
File "D:\Practice Projects\screenshot-to-code\backend\main.py", line 4, in
load_dotenv()
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 346, in load_dotenv
return dotenv.set_as_environment_variables()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 91, in set_as_environment_variables
if not self.dict():
^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 75, in dict
self._dict = OrderedDict(resolve_variables(raw_values, override=self.override))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 233, in resolve_variables
for (name, value) in values:
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 83, in parse
for mapping in with_warn_for_invalid_lines(parse_stream(stream)):
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 25, in with_warn_for_invalid_lines
for mapping in mappings:
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\parser.py", line 173, in parse_stream
reader = Reader(stream)
^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\parser.py", line 64, in init
self.string = stream.read()
^^^^^^^^^^^^^
File "", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

@vithanhlam
Copy link

Front end => OK

cd backend => OK echo "OPENAI_API_KEY=sk-your-key" > .env => OK poetry install => OK poetry shell => OK poetry run uvicorn main:app --reload --port 7001 => Not working

I'm not familiar with Python code, so I tried to follow the instructions, but when I ran the final command to run the backend project, I encountered the following error. How should I fix this issue? Can someone please help me? :(

poetry run uvicorn main:app --reload --port 7001 INFO: Will watch for changes in these directories: ['D:\Practice Projects\screenshot-to-code\backend'] INFO: Uvicorn running on http://127.0.0.1:7001 (Press CTRL+C to quit) INFO: Started reloader process [16448] using StatReload Process SpawnProcess-1: Traceback (most recent call last): File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 314, in _bootstrap self.run() File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 108, in run self._target(*self._args, **self.kwargs) File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn_subprocess.py", line 76, in subprocess_started target(sockets=sockets) File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\server.py", line 61, in run return asyncio.run(self.serve(sockets=sockets)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run return self.loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\server.py", line 68, in serve config.load() File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\config.py", line 467, in load self.loaded_app = import_from_string(self.app) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\importer.py", line 21, in import_from_string module = importlib.import_module(module_str) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\importlib__init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1381, in _gcd_import File "", line 1354, in _find_and_load File "", line 1325, in _find_and_load_unlocked File "", line 929, in _load_unlocked File "", line 994, in exec_module File "", line 488, in _call_with_frames_removed File "D:\Practice Projects\screenshot-to-code\backend\main.py", line 4, in load_dotenv() File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 346, in load_dotenv return dotenv.set_as_environment_variables() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 91, in set_as_environment_variables if not self.dict(): ^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 75, in dict self._dict = OrderedDict(resolve_variables(raw_values, override=self.override)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 233, in resolve_variables for (name, value) in values: File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 83, in parse for mapping in with_warn_for_invalid_lines(parse_stream(stream)): File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 25, in with_warn_for_invalid_lines for mapping in mappings: File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\parser.py", line 173, in parse_stream reader = Reader(stream) ^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\parser.py", line 64, in init self.string = stream.read() ^^^^^^^^^^^^^ File "", line 322, in decode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

You open the .env file with notepad++ then go to Encoding and select UTF-8

@imsamm04
Copy link

imsamm04 commented Nov 20, 2023

Front end => OK
cd backend => OK echo "OPENAI_API_KEY=sk-your-key" > .env => OK poetry install => OK poetry shell => OK poetry run uvicorn main:app --reload --port 7001 => Not working
I'm not familiar with Python code, so I tried to follow the instructions, but when I ran the final command to run the backend project, I encountered the following error. How should I fix this issue? Can someone please help me? :(
poetry run uvicorn main:app --reload --port 7001 INFO: Will watch for changes in these directories: ['D:\Practice Projects\screenshot-to-code\backend'] INFO: Uvicorn running on http://127.0.0.1:7001 (Press CTRL+C to quit) INFO: Started reloader process [16448] using StatReload Process SpawnProcess-1: Traceback (most recent call last): File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 314, in _bootstrap self.run() File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 108, in run self._target(*self._args, **self.kwargs) File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn_subprocess.py", line 76, in subprocess_started target(sockets=sockets) File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\server.py", line 61, in run return asyncio.run(self.serve(sockets=sockets)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run return self.loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\server.py", line 68, in serve config.load() File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\config.py", line 467, in load self.loaded_app = import_from_string(self.app) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\importer.py", line 21, in import_from_string module = importlib.import_module(module_str) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\importlib__init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1381, in _gcd_import File "", line 1354, in _find_and_load File "", line 1325, in _find_and_load_unlocked File "", line 929, in _load_unlocked File "", line 994, in exec_module File "", line 488, in _call_with_frames_removed File "D:\Practice Projects\screenshot-to-code\backend\main.py", line 4, in load_dotenv() File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 346, in load_dotenv return dotenv.set_as_environment_variables() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 91, in set_as_environment_variables if not self.dict(): ^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 75, in dict self._dict = OrderedDict(resolve_variables(raw_values, override=self.override)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 233, in resolve_variables for (name, value) in values: File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 83, in parse for mapping in with_warn_for_invalid_lines(parse_stream(stream)): File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 25, in with_warn_for_invalid_lines for mapping in mappings: File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\parser.py", line 173, in parse_stream reader = Reader(stream) ^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\parser.py", line 64, in init self.string = stream.read() ^^^^^^^^^^^^^ File "", line 322, in decode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

You open the .env file with notepad++ then go to Encoding and select UTF-8

Thank you, it worked, but I encountered another problem when importing a photo . The UI reports an error saying, 'Error generating code. Check the Developer Console for details. Feel free to open a Github issue.'

The terminal at the BE (Backend) is reporting an error as follows:

poetry run uvicorn main:app --reload --port 7001
INFO: Will watch for changes in these directories: ['D:\Practice Projects\screenshot-to-code\backend']
INFO: Uvicorn running on http://127.0.0.1:7001 (Press CTRL+C to quit)
INFO: Started reloader process [1480] using StatReload
INFO: Started server process [2408]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: ('127.0.0.1', 51398) - "WebSocket /generate-code" [accepted]
INFO: connection open
Using OpenAI API key from environment variable
generating code...
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 247, in run_asgi
result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\fastapi\applications.py", line 276, in call
await super().call(scope, receive, send)
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\starlette\applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\starlette\middleware\errors.py", line 149, in call
await self.app(scope, receive, send)
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in call
raise exc
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in call
raise e
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in call
await self.app(scope, receive, send)
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\starlette\routing.py", line 718, in call
await route.handle(scope, receive, send)
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\starlette\routing.py", line 341, in handle
await self.app(scope, receive, send)
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\starlette\routing.py", line 82, in app
await func(session)
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\fastapi\routing.py", line 289, in app
await dependant.call(**values)
File "D:\Practice Projects\screenshot-to-code\backend\main.py", line 100, in stream_code_test
completion = await stream_openai_response(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Practice Projects\screenshot-to-code\backend\llm.py", line 23, in stream_openai_response
completion = await client.chat.completions.create(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\openai\resources\chat\completions.py", line 1191, in create
return await self._post(
^^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\openai_base_client.py", line 1474, in post
return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\openai_base_client.py", line 1275, in request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\openai_base_client.py", line 1318, in _request
raise self._make_status_error_from_response(err.response) from None
openai.NotFoundError: Error code: 404 - {'error': {'message': 'The model gpt-4-vision-preview does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}
INFO: connection closed

@PristineJagan
Copy link

I'm getting this error while insert screen shot
Error

@abi
Copy link
Owner

abi commented Nov 20, 2023

@imsamm04 the last line in your logs "message': 'The model gpt-4-vision-preview does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}". Please see the FAQ for how to get an open ai key that has access to the vision model.

@abi
Copy link
Owner

abi commented Nov 20, 2023

@PristineJagan are you running locally? If so please look at backends logs.

If it's hosted, not offering support for the demo at the moment. Please run locally.

@nhuanh9
Copy link

nhuanh9 commented Nov 20, 2023

I run with docker and have error likes PristineJagan

@abi
Copy link
Owner

abi commented Nov 20, 2023

@Jonathan-Adly any thoughts on the Docker issues here?

Also, folks, please open a new issue. I'm going to lock this issue in the future since I don't want lots of different discussions going on in one issue.

@Jonathan-Adly
Copy link
Contributor

Guys - open your console, and let us know what it says there so we can help you! Also - make sure you are running with the last code where @abi changed the port. Port 7000 doesn't work on some Macs and docker. It is occupied by Airplay.

@imsamm04
Copy link

imsamm04 commented Nov 21, 2023

@imsamm04 the last line in your logs "message': 'The model gpt-4-vision-preview does not exist or you do not have access to it. Learn more: https://help.openai.com/en/articles/7102672-how-can-i-access-gpt-4.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}". Please see the FAQ for how to get an open ai key that has access to the vision model.

thanks , its working now

@donghero
Copy link

Front end => OK
cd backend => OK echo "OPENAI_API_KEY=sk-your-key" > .env => OK poetry install => OK poetry shell => OK poetry run uvicorn main:app --reload --port 7001 => Not working
I'm not familiar with Python code, so I tried to follow the instructions, but when I ran the final command to run the backend project, I encountered the following error. How should I fix this issue? Can someone please help me? :(
poetry run uvicorn main:app --reload --port 7001 INFO: Will watch for changes in these directories: ['D:\Practice Projects\screenshot-to-code\backend'] INFO: Uvicorn running on http://127.0.0.1:7001 (Press CTRL+C to quit) INFO: Started reloader process [16448] using StatReload Process SpawnProcess-1: Traceback (most recent call last): File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 314, in _bootstrap self.run() File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 108, in run self._target(*self._args, **self.kwargs) File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn_subprocess.py", line 76, in subprocess_started target(sockets=sockets) File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\server.py", line 61, in run return asyncio.run(self.serve(sockets=sockets)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run return self.loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\server.py", line 68, in serve config.load() File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\config.py", line 467, in load self.loaded_app = import_from_string(self.app) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\uvicorn\importer.py", line 21, in import_from_string module = importlib.import_module(module_str) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\Programs\Python\Python312\Lib\importlib__init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1381, in _gcd_import File "", line 1354, in _find_and_load File "", line 1325, in _find_and_load_unlocked File "", line 929, in _load_unlocked File "", line 994, in exec_module File "", line 488, in _call_with_frames_removed File "D:\Practice Projects\screenshot-to-code\backend\main.py", line 4, in load_dotenv() File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 346, in load_dotenv return dotenv.set_as_environment_variables() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 91, in set_as_environment_variables if not self.dict(): ^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 75, in dict self._dict = OrderedDict(resolve_variables(raw_values, override=self.override)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 233, in resolve_variables for (name, value) in values: File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 83, in parse for mapping in with_warn_for_invalid_lines(parse_stream(stream)): File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\main.py", line 25, in with_warn_for_invalid_lines for mapping in mappings: File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\parser.py", line 173, in parse_stream reader = Reader(stream) ^^^^^^^^^^^^^^ File "C:\Users\ducvi\AppData\Local\pypoetry\Cache\virtualenvs\backend-Mnz77ySr-py3.12\Lib\site-packages\dotenv\parser.py", line 64, in init self.string = stream.read() ^^^^^^^^^^^^^ File "", line 322, in decode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

You open the .env file with notepad++ then go to Encoding and select UTF-8

Nice Comment! It works for me! Thanks a lot!

@hkcitizens9527
Copy link

I'm getting this error while insert screen shot Error

me too

@abi
Copy link
Owner

abi commented Nov 21, 2023

Going to lock this conversation. Please open a new ticket if you have issues that are not solved by the FAQ section.

Repository owner locked as resolved and limited conversation to collaborators Nov 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

14 participants