screenshot-to-code: Cannot install
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? )
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Comments: 29 (10 by maintainers)
Nice Comment! It works for me! Thanks a lot!
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 “<frozen importlib._bootstrap>”, line 1381, in _gcd_import File “<frozen importlib._bootstrap>”, line 1354, in _find_and_load File “<frozen importlib._bootstrap>”, line 1325, in _find_and_load_unlocked File “<frozen importlib._bootstrap>”, line 929, in _load_unlocked File “<frozen importlib._bootstrap_external>”, line 994, in exec_module File “<frozen importlib._bootstrap>”, line 488, in _call_with_frames_removed File “D:\Practice Projects\screenshot-to-code\backend\main.py”, line 4, in <module> 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 “<frozen codecs>”, line 322, in decode UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte
Ok, this worked for me:
And
frontend
stuff stays the same.I suppose an easier solution would be to do
mv pyproject.toml ../
You open the .env file with notepad++ then go to Encoding and select UTF-8
Thanks guys. That worked pretty well!
actually I proceed with the last command, and it works fine!
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 👍
@AntouanK People have gotten it working on their machine: https://github.com/abi/screenshot-to-code/issues/6
I tried locally from scratch (but not in a Docker container). Let me look into it.
you can install
pip install poetry