Attributeerror: 'nonetype' Object Has No Attribute 'sslcontext' Running Flask Script In Pycharm 2018.3.7 On Win10
Solution 1:
FLASK_APP
should have your flask module.
flask quickstart would be helpful.
you need to tell your terminal the application to work with by exporting the FLASK_APP environment variable
BTW, pycharm provides easy way to create flask app. This link also helps you.
Here is my simple example.
$ cat hello.py
from flask import Flask
app = Flask(__name__)
@app.route("/")defhello():
return"hello world"
$ env FLASK_APP=hello.py flask run
* Serving Flask app "hello.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [12/Apr/202012:13:04] "GET / HTTP/1.1"200 -
Solution 2:
You must run it from the anaconda prompt in the right environment.
(data-class) C:\Users\Faramarz>cd /d D:\...\surfs_up
(data-class) D:\...\surfs_up>set FLASK_APP=app.py
(data-class) D:\...\surfs_up>flask run
* Serving Flask app "app.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [18/Oct/2020 17:27:47] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [18/Oct/2020 17:27:47] "GET /favicon.ico HTTP/1.1" 404 -
Solution 3:
I had this problem and could not get my Flask App to work through VS Code. There is something wrong with my environment so I searched my computer for the Anaconda Powershell, cd into the correct folder, and then typed: set FLASK_APP=app.py and ran that.
When it did not throw an error I ran flask run in the next line and it gave me my local address. One error that the powershell threw out was it could not find my file because it did not exist so I changed the file to app.py and it worked.
Solution 4:
This has occured due to not setting env variables properly.
try these in terminal
set FLASK_APP=your_application_file_name.py
set FLASK_ENV=development
If this still fails try adding env variables to user variables using GUI. In my case the adding FLASK_APP : your_application_file_name.py did the job.
Post a Comment for "Attributeerror: 'nonetype' Object Has No Attribute 'sslcontext' Running Flask Script In Pycharm 2018.3.7 On Win10"