While attempting to create my first flask application, I created a virtual environment and used pip install Flask
to attempt to install the flask module in the VScode terminal. This appears to have worked successfully.
However, when running this code:
from flask import Flask, redirect, url_for, request, render_template, session
app = Flask(__name__)
I receive the following output from the terminal:
c:\Users\srija\Desktop\MLProjects\flask_ai\venv\Scripts\python.exe: No module named flask
I have attempted multiple different methods of installation from similar questions on this site, none of which produce a unique output. I believe that I have conceptual error from my lack of understanding. Any suggestions?
CodePudding user response:
Please check where you have installed the flask module through the command of pip show flask
, make sure you have installed it in the venv
virtual environment.
CodePudding user response:
Sorry for giving random advice instead of answering your question, but you don't really need to use virtual environments for such simple projects. It overcomplicates things for no reason. Just use your system's (latest) Python/Flask if you don't need a specific version. venv
is supposed to protect from dependency hell on servers where multiple Python programs with different hardcoded versions of dependencies are deployed.