title: SyntaxError: invalid or missing encoding declaration in debug mode in flask app but not in run mode
body: <p>I'm seeing the following error while in debug mode only in PyCharm (pressing the 'bug' button). It does not hit the breakpoint but fails while loading the flask.exe file. </p>
  
  <pre><code>C:\ProgramData\Anaconda3\envs\workflow_webapp\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 55286 --file C:/ProgramData/Anaconda3/envs/workflow_webapp/Scripts/flask.exe run
  pydev debugger: process 18788 is connecting
  
  Connected to pydev debugger (build 183.5429.31)
  Traceback (most recent call last):
    File "C:\ProgramData\Anaconda3\envs\workflow_webapp\lib\tokenize.py", line 390, 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.3.2\helpers\pydev\pydevd.py", line 1741, in &lt;module&gt;
      main()
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\pydevd.py", line 1735, in main
      globals = debugger.run(setup['file'], None, None, is_module)
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\pydevd.py", line 1135, in run
      pydev_imports.execfile(file, globals, locals)  # execute the script
    File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 11, in execfile
      stream = tokenize.open(file)  # @UndefinedVariable
    File "C:\ProgramData\Anaconda3\envs\workflow_webapp\lib\tokenize.py", line 454, in open
      encoding, lines = detect_encoding(buffer.readline)
    File "C:\ProgramData\Anaconda3\envs\workflow_webapp\lib\tokenize.py", line 431, in detect_encoding
      encoding = find_cookie(first)
    File "C:\ProgramData\Anaconda3\envs\workflow_webapp\lib\tokenize.py", line 395, in find_cookie
      raise SyntaxError(msg)
  SyntaxError: invalid or missing encoding declaration for 'C:/ProgramData/Anaconda3/envs/workflow_webapp/Scripts/flask.exe'
  </code></pre>
  
  <p>Here is the <a href="https://i.stack.imgur.com/8bJjt.png" rel="noreferrer">debug configuration</a>.</p>
  
  <p>The app runs fine in normal mode:</p>
  
  <pre><code>&gt; C:\ProgramData\Anaconda3\envs\workflow_webapp\python.exe
  &gt; C:/ProgramData/Anaconda3/envs/workflow_webapp/Scripts/flask.exe run  *
  &gt; Serving Flask app "workflow.py"  * Environment: production    WARNING:
  &gt; Do not use the development server in a production environment.    Use
  &gt; a production WSGI server instead.  * Debug mode: off  * Running on
  &gt; http://127.0.0.1:5000/ (Press CTRL+C to quit)
  </code></pre>
  
  <p>The <a href="https://i.stack.imgur.com/TEOBn.png" rel="noreferrer">run configuration</a> is here.</p>
  
  <p>The versions are:</p>
  
  <ul>
  <li><p>Python version on Windows 10: Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 18:50:55) [MSC v.1915 64 bit (AMD64)] on win32</p></li>
  <li><p>Flask version: 1.0.2</p></li>
  <li><p>Pycharm: 2018.3.2</p></li>
  </ul>
  
  <p>Any guidance would be much appreciated. </p>