I am a beginner with the python programming. I have python 3 installed in my local system. I coding along as part of a tutorial video and as part of the tutorial, i have created a virtual environment and created an app.py file with the below content.
from flask import Flask app = Flask(__name__) @app.route("/") def index(): return "Hello, World!" if __name__ == "__main__": app.run()
I have installed all the dependencies like flask and pytest in the virtual environment as per the tutorial using gitbash.But when i run the command python3 app.py in gitbash i get the below error message
File "C:pathPythonpython-github-actions-examplesrcapp.py", line 1, in <module> from flask import Flask ModuleNotFoundError: No module named 'flask' (myvenv)
I checked the python version and it is python 3.9.7
If i run python app.py i get the output. Why is it not running even though correct version is installed
Any idea why ?
Advertisement
Answer
Try to delete the venv
or make a new one.
Then create a new
venv
like this:virtualenv flask
Go to the flask directory :
cd flask
Activate it:
scriptsactivate
- You should see (flask) on the left of the command line.
Install flask again:
pip install flask
Run your file again.