screenshot-to-code icon indicating copy to clipboard operation
screenshot-to-code copied to clipboard

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

Open yxf-git opened this issue 2 years ago • 3 comments

Process SpawnProcess-1: Traceback (most recent call last): File "D:\python\python310\lib\multiprocessing\process.py", line 314, in _bootstrap self.run() File "D:\python\python310\lib\multiprocessing\process.py", line 108, in run self._target(*self._args, **self.kwargs) File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\uvicorn_subprocess.py", line 76, in subprocess_started target(sockets=sockets) File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\uvicorn\server.py", line 61, in run return asyncio.run(self.serve(sockets=sockets)) File "D:\python\python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "D:\python\python310\lib\asyncio\base_events.py", line 649, in run_until_complete return future.result() File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\uvicorn\server.py", line 68, in serve config.load() File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\uvicorn\config.py", line 467, in load self.loaded_app = import_from_string(self.app) File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\uvicorn\importer.py", line 21, in import_from_string module = importlib.import_module(module_str) File "D:\python\python310\lib\importlib_init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "D:\www\LLM\screenshot-to-code\backend\backend\main.py", line 5, in load_dotenv() File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\dotenv\main.py", line 346, in load_dotenv return dotenv.set_as_environment_variables() File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\dotenv\main.py", line 91, in set_as_environment_variables if not self.dict(): File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\dotenv\main.py", line 75, in dict self._dict = OrderedDict(resolve_variables(raw_values, override=self.override)) File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\dotenv\main.py", line 233, in resolve_variables for (name, value) in values: File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\dotenv\main.py", line 83, in parse for mapping in with_warn_for_invalid_lines(parse_stream(stream)): File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\dotenv\main.py", line 25, in with_warn_for_invalid_lines for mapping in mappings: File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\dotenv\parser.py", line 173, in parse_stream reader = Reader(stream) File "C:\Users\36121\AppData\Local\pypoetry\Cache\virtualenvs\backend-I4rE4aR--py3.10\lib\site-packages\dotenv\parser.py", line 64, in init self.string = stream.read() File "D:\python\python310\lib\codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

yxf-git avatar Dec 05 '23 02:12 yxf-git

Change the encoding of your env file to utf-8

seven2202 avatar Dec 05 '23 03:12 seven2202

Change the encoding of your env file to utf-8

Can you guide me on where to make this change?

UPDATE: I used Notepad++ to do it, and now it works!

Screenshot 2023-12-15 051453

anujalamahewaneuralleap avatar Dec 14 '23 16:12 anujalamahewaneuralleap

As a sidenote to anybody who experiences this issue and does not have Notepad++ installed. You can also open the file in the regular Notepad and click "File" -> "Save As". You will have the the option to change the encoding at the bottom to UTF-8. This has solved the issue above for me.

Edit: typo

CaptainCsaba avatar Dec 15 '23 12:12 CaptainCsaba

Thanks for the fix. Included in the README now.

abi avatar May 21 '24 17:05 abi