I was trying to create a Flask app in my virtual environment on Windowns 10.
I've created the environment using python -m venv flask_ven
In VS code, Python:Select Intrepreter
, I chose Python 3.7.5("flask_evn":venv)
I have a simple code to test the connection
from distutils.log import debug
from flask import Flask
app = Flask("mpg_prediction") ## give it a name
@app.route('/', methods=['GET']) ## test if the app is working
def ping():
return "Pinging Model Application!!"
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=9696)
But I tried to run it, it says flask is not installed.
I tried pip freeze
in the terminal, then it says flask is installed Flask==2.1.2
I'm so puzzled.
When I was activating the virtual enviroment, I did come into an error
PS C:\Users\CSu.CL\Desktop\fuel consumption> & "c:/Users/CSu.CL/Desktop/fuel consumption/flask_env/Scripts/Activate.ps1"
& : File C:\Users\CSu.CL\Desktop\fuel consumption\flask_env\Scripts\Activate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see
At line:1 char:3
+ & "c:/Users/CSu.CL/Desktop/fuel consumption/flask_env/Scripts/Activat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Has it got anything to do with not finding flask?