Running Flask dev server in Python 3.6 raises ImportError for SocketServer and ForkingMixIn
<p>I am trying to run a basic Flask app using Python 3.6.  However, I get an <code>ImportError: cannot import name 'ForkingMixIn'</code>.  I don't get this error when running with Python 2.7 or 3.5.  How can I run Flask with Python 3.6?</p>

<pre><code>from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello, World!"
</code></pre>



<pre><code>Traceback (most recent call last):
  File "C:\Python36\lib\site-packages\werkzeug\serving.py", line 65, in &lt;module&gt;
    from SocketServer import ThreadingMixIn, ForkingMixIn
ImportError: No module named 'SocketServer'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\fsk.py", line 9, in &lt;module&gt;
    app.run()
  File "C:\Python36\lib\site-packages\flask\app.py", line 828, in run
    from werkzeug.serving import run_simple
  File "C:\Python36\lib\site-packages\werkzeug\serving.py", line 68, in &lt;module&gt;
    from socketserver import ThreadingMixIn, ForkingMixIn
ImportError: cannot import name 'ForkingMixIn'
</code></pre>

<p>This is a known issue that was <a href="https://github.com/pallets/werkzeug/pull/999" rel="nofollow">reported to Werkzeug</a> in anticipation of Python 3.6.  Until that or another patch is merged and released, Werkzeug's dev server will not run on Python 3.6.</p>

<blockquote>
  <p>Check if OS can fork before importing <code>ForkingMixIn</code> since Python 3.6 will no longer define that when it is not available on the operating system (<a href="https://github.com/python/cpython/commit/aadff9bea61a2fc9f4cf0f213f0ee50fc54d6574" rel="nofollow">python/cpython@aadff9b</a>) and <code>ImportError: cannot import name 'ForkingMixIn'</code> will occur.</p>
</blockquote>

<p>In the mean time, you can run your app with an external WSGI server such as Gunicorn.</p>

<pre><code>pip install gunicorn
gunicorn my_app:app
</code></pre>

<p>You can wrap your app in the <a href="http://werkzeug.pocoo.org/docs/0.11/debug/#werkzeug.debug.DebuggedApplication" rel="nofollow">debug middleware</a> if you need the in-page debugger (as long as you only run Gunicorn with one worker).</p>

python flask werkzeug python-3.6