3

I'm trying to configure debugger for Flask application in PyCharm IDE.

Here is how configuration looks like: enter image description here

Running app manually from command line and running app without debugging in PyCharm works well. Problems appear when I click on Debug button in PyCharm. Here is an error I see after trying to run it:

Traceback (most recent call last):
  File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\tokenize.py", line 385, in find_cookie
    line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\pydevd.py", line 1664, in <module>
    main()
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\pydevd.py", line 1658, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\pydevd.py", line 1068, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 11, in execfile
    stream = tokenize.open(file)  # @UndefinedVariable
  File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\tokenize.py", line 449, in open
    encoding, lines = detect_encoding(buffer.readline)
  File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\tokenize.py", line 426, in detect_encoding
    encoding = find_cookie(first)
  File "C:\Users\username\AppData\Local\Programs\Python\Python37-32\lib\tokenize.py", line 390, in find_cookie
    raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for 'P:/PROJECTS_PYTHON/messenger_chatbot/venv/Scripts/flask.exe'

Do you have any ideas what could go wrong?

Platform: Windows 10

Piotrek
  • 10,919
  • 18
  • 73
  • 136
  • 1
    How do you run it from command line and without debugging? You use `flask run` to run it? That's the problem.debugger is actually a wrapper, or let's say it is a connector. It must runs a .py file. Basically you can image there is a command named `debug`, and if you run debugger from command line it should be `debug xx.py`, but you cannot run it as `debug flask xx.py` while flask is not a python script. – Sraw Oct 01 '18 at 18:56

0 Answers0