python - Running Flask app on Windows raises "an operation was attempted on something that is not a socket" -
when running basic flask app getting error in shell , can't find how solve this.
running on http://127.0.0.1:5000/ (press ctrl+c quit) <br/> restarting stat<br/> debugger active!<br/> debugger pin code: 295-257-376<br/> exception in thread thread-1:<br/> traceback (most recent call last):<br/> file "c:\users\admin\appdata\local\programs\python\python35-32\lib\threading.py", line 923, in _bootstrap_inner self.run()<br/> file "c:\users\admin\appdata\local\programs\python\python35-32\lib\threading.py", line 871, in run self._target(*self._args, **self._kwargs) <br/> file "c:\users\admin\appdata\local\programs\python\python35-32\lib\site-packages\werkzeug\serving.py", line 656, in inner fd=fd)<br/> file "c:\users\admin\appdata\local\programs\python\python35-32\lib\site-packages\werkzeug\serving.py", line 550, in make_server passthrough_errors, ssl_context, fd=fd)<br/> file "c:\users\admin\appdata\local\programs\python\python35-32\lib\site-packages\werkzeug\serving.py", line 462, in __init__ socket.sock_stream)<br/> file "c:\users\admin\appdata\local\programs\python\python35-32\lib\socket.py", line 446, in fromfd nfd = dup(fd)<br/> oserror: [winerror 10038] operation attempted on not socket
from flask import flask, render_template app = flask(__name__) @app.route('/') def main(): return render_template('main.html') app.run(debug=true)
you're trying execute global python installation. "good practice" use virtual environments python projects keep each projects' pip install separate.
start running pip install virtualenv
then, navigate projects folder , execute virtualenv example-virtual-env
. create new folder own python , pip installation. (it supports virtual environments python 3 well.)
now in shell, execute <projects_folder>\scripts\activate
activates virtual environment. every pip install
execute within environment (note environment name before shell cursor.)
in here, run pip install flask
, run flask application.
if you're still experiencing issue, try running cmd in administrator mode.
Comments
Post a Comment