A
A
Alex_analytik2021-03-01 11:38:07
PyCharm
Alex_analytik, 2021-03-01 11:38:07

How to solve decode('utf-8') problem with debugger in PyCharm?

An error occurs when trying to use the debugger in PyCharm. Moreover, restarting the debugger 20 or 30 times in a row allows you to work it out once. In other cases, it gives the following error:

C:\Python38\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2020.1\plugins\python-ce\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 56033 --file "C:/Users/Newman/Google Диск/Geekbrains/Методы сбора и обработки данных из сети Интернет/Sacrapy_main/auctionsWhiskeys/one_auc_price_renew.py"
Connected to pydev debugger (build 203.7148.72)
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.1\plugins\python-ce\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 301, in _on_run
    r = r.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd1 in position 1023: unexpected end of data

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kamenyuga, 2021-03-01
@kamenyuga

One of the great features of python is that everything python in it is completely open and available - objects at run time and code in a readable test form. So if you open the file indicated in the error message - by the way, this requires one click in the paycharm - then exactly before the problematic line there is a big warning about the encoding of strings, and Python 2 version and operating system encoding are also mentioned separately. Inside paycharm only utf-8 and nothing else. And Windows still uses a huge scattering of encodings, because utf-8 was not created by Microsoft, Cyrillic is usually windows-1251 in our time.
So the solutions to the problem are obvious - switch to Python 3 and use only ascii characters in the names of folders and files. Here the second condition is not met. And whether this is the root of evil - I do not know.
By the way, the paycharm debugger launch command looks different for me and there are no problems with Cyrillic on windows 10. So, maybe the launch method also spoils everything. I don't have this part "C:\Python38\python.exe" and no quotes around file paths. I use virtual environments created in anaconda and specified in the project properties, and then I just click on the green beetle icon to start debugging.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question