<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">Place the following code into <code class="notranslate">main.py</code>.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from flask import Flask


app = Flask(__name__)
app.config['DEBUG'] = True

@app.route('/')
def root():
    return &quot;:)&quot;

app.run()"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">flask</span> <span class="pl-k">import</span> <span class="pl-v">Flask</span>


<span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-v">Flask</span>(<span class="pl-s1">__name__</span>)
<span class="pl-s1">app</span>.<span class="pl-s1">config</span>[<span class="pl-s">'DEBUG'</span>] <span class="pl-c1">=</span> <span class="pl-c1">True</span>

<span class="pl-en">@<span class="pl-s1">app</span>.<span class="pl-en">route</span>(<span class="pl-s">'/'</span>)</span>
<span class="pl-k">def</span> <span class="pl-en">root</span>():
    <span class="pl-k">return</span> <span class="pl-s">":)"</span>

<span class="pl-s1">app</span>.<span class="pl-en">run</span>()</pre></div>
<p dir="auto">Set the execute bit  on <code class="notranslate">main.py</code>:<br>
<code class="notranslate">chmod +x main.py</code><br>
Running the following command should start the server: <code class="notranslate">python main.py</code></p>
<h3 dir="auto">Actual Behavior</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ python main.py
 * Serving Flask app &quot;main&quot; (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
Traceback (most recent call last):
  File &quot;main.py&quot;, line 11, in &lt;module&gt;
    app.run()
  File &quot;/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/site-packages/flask/app.py&quot;, line 943, in run
    run_simple(host, port, self, **options)
  File &quot;/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/site-packages/werkzeug/serving.py&quot;, line 988, in run_simple
    run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
  File &quot;/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/site-packages/werkzeug/_reloader.py&quot;, line 332, in run_with_reloader
    sys.exit(reloader.restart_with_reloader())
  File &quot;/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/site-packages/werkzeug/_reloader.py&quot;, line 176, in restart_with_reloader
    exit_code = subprocess.call(args, env=new_environ, close_fds=False)
  File &quot;/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/subprocess.py&quot;, line 323, in call
    with Popen(*popenargs, **kwargs) as p:
  File &quot;/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/subprocess.py&quot;, line 775, in __init__
    restore_signals, start_new_session)
  File &quot;/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/subprocess.py&quot;, line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/Users/wadegilmer/lc101/flask_error/main.py'"><pre lang="pyb" class="notranslate"><code class="notranslate">$ python main.py
 * Serving Flask app "main" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat
Traceback (most recent call last):
  File "main.py", line 11, in &lt;module&gt;
    app.run()
  File "/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/site-packages/flask/app.py", line 943, in run
    run_simple(host, port, self, **options)
  File "/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/site-packages/werkzeug/serving.py", line 988, in run_simple
    run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
  File "/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/site-packages/werkzeug/_reloader.py", line 332, in run_with_reloader
    sys.exit(reloader.restart_with_reloader())
  File "/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/site-packages/werkzeug/_reloader.py", line 176, in restart_with_reloader
    exit_code = subprocess.call(args, env=new_environ, close_fds=False)
  File "/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/subprocess.py", line 323, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/Users/wadegilmer/miniconda3/envs/hello-flask/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/Users/wadegilmer/lc101/flask_error/main.py'
</code></pre></div>
<h3 dir="auto">Environment</h3>
<ul dir="auto">
<li>osx version: 10.13.6</li>
<li>Python version: 3.7.3</li>
<li>Flask version: 1.0.2</li>
<li>Werkzeug version: 0.15.2</li>
</ul>
<h3 dir="auto">Commentary</h3>
<p dir="auto">Adding a shabang line to <code class="notranslate">main.py</code> resolves the issue but is kind of unexpected. Additionally removing the execute bit also resolves the issue. Is this the expected behavior?</p>
<p dir="auto">The new 0.15.0 does not run in Docker for Windows. Have not tried Docker on other platforms.</p>
<p dir="auto">Minimal example with Flask.</p>
<p dir="auto">app.py</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from flask import Flask
 
app = Flask(__name__)
 
 
@app.route('/')
def hello_world():
    return 'Hello, world!'
 
if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0')"><pre class="notranslate"><code class="notranslate">from flask import Flask
 
app = Flask(__name__)
 
 
@app.route('/')
def hello_world():
    return 'Hello, world!'
 
if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0')
</code></pre></div>
<p dir="auto">Dockerfile</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="FROM python:3-onbuild
COPY . /usr/src/app
CMD [&quot;python&quot;, &quot;app.py&quot;]"><pre class="notranslate"><code class="notranslate">FROM python:3-onbuild
COPY . /usr/src/app
CMD ["python", "app.py"]
</code></pre></div>
<p dir="auto">requirements.txt</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# Werkzeug==0.14.1
Flask"><pre class="notranslate"><code class="notranslate"># Werkzeug==0.14.1
Flask
</code></pre></div>
<p dir="auto">Run <code class="notranslate">docker build -t flask_test .</code> and then <code class="notranslate">docker run flask_test</code>.<br>
Error in container:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="λ docker run flask_test
 * Serving Flask app &quot;app&quot; (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
 * Restarting with stat
Traceback (most recent call last):
  File &quot;app.py&quot;, line 11, in &lt;module&gt;
    app.run(debug=True, host='0.0.0.0')
  File &quot;/usr/local/lib/python3.6/site-packages/flask/app.py&quot;, line 943, in run
    run_simple(host, port, self, **options)
  File &quot;/usr/local/lib/python3.6/site-packages/werkzeug/serving.py&quot;, line 988, in run_simple
    run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
  File &quot;/usr/local/lib/python3.6/site-packages/werkzeug/_reloader.py&quot;, line 332, in run_with_reloader
    sys.exit(reloader.restart_with_reloader())
  File &quot;/usr/local/lib/python3.6/site-packages/werkzeug/_reloader.py&quot;, line 176, in restart_with_reloader
    exit_code = subprocess.call(args, env=new_environ, close_fds=False)
  File &quot;/usr/local/lib/python3.6/subprocess.py&quot;, line 267, in call
    with Popen(*popenargs, **kwargs) as p:
  File &quot;/usr/local/lib/python3.6/subprocess.py&quot;, line 709, in __init__
    restore_signals, start_new_session)
  File &quot;/usr/local/lib/python3.6/subprocess.py&quot;, line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/usr/src/app/app.py"><pre class="notranslate"><code class="notranslate">λ docker run flask_test
 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
 * Restarting with stat
Traceback (most recent call last):
  File "app.py", line 11, in &lt;module&gt;
    app.run(debug=True, host='0.0.0.0')
  File "/usr/local/lib/python3.6/site-packages/flask/app.py", line 943, in run
    run_simple(host, port, self, **options)
  File "/usr/local/lib/python3.6/site-packages/werkzeug/serving.py", line 988, in run_simple
    run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
  File "/usr/local/lib/python3.6/site-packages/werkzeug/_reloader.py", line 332, in run_with_reloader
    sys.exit(reloader.restart_with_reloader())
  File "/usr/local/lib/python3.6/site-packages/werkzeug/_reloader.py", line 176, in restart_with_reloader
    exit_code = subprocess.call(args, env=new_environ, close_fds=False)
  File "/usr/local/lib/python3.6/subprocess.py", line 267, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/local/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/usr/src/app/app.py
</code></pre></div>
<p dir="auto">Uncomment the first line in <code class="notranslate">requirements.txt</code> and it runs properly after rebuild.</p>