2

I'm trying to run flask through pycharm 2019.2.2 through debug. This issue happens with any projects trying to use flask and difference virtual env flask executables. I am able to just run the project with the same configuration and that works without any issues only debugging causes the problem

I've tried

  • Clearing out python version and reinstalling from scratch
  • Reinstalling pycharm
  • As stated above, different projects/venvs

The second project I'm trying is extremely simple


app = Flask(__name__)

@app.route('/')
def hello():
    return 'hello world'

Configuration looks like Configuration

Trace below

pydev debugger: process 13372 is connecting

Connected to pydev debugger (build 192.6603.34)
Traceback (most recent call last):
  File "C:\Users\User\Coding\TestFlask\env\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\pycharm\PyCharm Community Edition 2019.2.2\helpers\pydev\pydevd.py", line 2066, in <module>
    main()
  File "C:\Program Files\pycharm\PyCharm Community Edition 2019.2.2\helpers\pydev\pydevd.py", line 2060, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files\pycharm\PyCharm Community Edition 2019.2.2\helpers\pydev\pydevd.py", line 1411, in run
    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
  File "C:\Program Files\pycharm\PyCharm Community Edition 2019.2.2\helpers\pydev\pydevd.py", line 1418, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\pycharm\PyCharm Community Edition 2019.2.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 11, in execfile
    stream = tokenize.open(file)  # @UndefinedVariable
  File "C:\Users\User\Coding\TestFlask\env\lib\tokenize.py", line 449, in open
    encoding, lines = detect_encoding(buffer.readline)
  File "C:\Users\User\Coding\TestFlask\env\lib\tokenize.py", line 426, in detect_encoding
    encoding = find_cookie(first)
  File "C:\Users\User\Coding\TestFlask\env\lib\tokenize.py", line 390, in find_cookie
    raise SyntaxError(msg)
SyntaxError: invalid or missing encoding declaration for 'C:/Users/User/Coding/TestFlask/env/Scripts/flask.exe'

Process finished with exit code 1

Any assistance is much appreciated

Jeremy Farmer
  • 425
  • 4
  • 14
  • This answer may help: https://stackoverflow.com/questions/51669527/run-flask-cli-command-with-pycharm-debugger – Erty Seidohl Sep 18 '19 at 05:37
  • Similarly this is the same as (unanswered) https://stackoverflow.com/questions/52597057/configuring-debugger-of-flask-app-in-pycharm-unicodedecodeerror-utf-8-codec – Erty Seidohl Sep 18 '19 at 05:37
  • Possible duplicate of [Using #-\*- coding: utf-8 -\*- does not remove "Non-ASCII character '\x90' in file hello.exe on line 1, but no encoding declared" error](https://stackoverflow.com/questions/21636811/using-coding-utf-8-does-not-remove-non-ascii-character-x90-in-file) – Erty Seidohl Sep 18 '19 at 05:40
  • @ErtySeidohl https://stackoverflow.com/questions/51669527/run-flask-cli-command-with-pycharm-debugger Switching it to a module instead of Script path worked perfectly. – Jeremy Farmer Sep 18 '19 at 11:36

0 Answers0