Issue
I have installed SQLAlchemy through the command line by:
pip install SQLAlchemy
and have also done:
pip install Flask-SQLAlchemy
I am trying to run these lines and it tells me I have an unresolved import:
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
I have ran
>>>import sqlalchemy
>>>sqlalchemy.__version__
In the python interpreter and it says I have version 1.3.17 installed so I believe that means that sqlalchemy is installed correctly but VS Code does not see it for some reason.
Any help is appreciated.
Solution
Did you create environment?
If no:
1.Create Environment:
On your file system, create a project folder for this tutorial, such as hello_flask.
In that folder, use the following command (as appropriate to your computer) to create a virtual environment named env based on your current interpreter:
# macOS/Linux
sudo apt-get install python3-venv # If needed
python3 -m venv env
# Windows
python -m venv env
2.Select
Open the project folder in VS Code by running code ., or by running VS Code and using the File > Open Folder command.
3. Set
In VS Code, open the Command Palette (View > Command Palette or (Ctrl+Shift+P)). Then select the Python: Select Interpreter command:
4.Activate env
source env/bin/activate (Linux/macOS)
or
env\scripts\activate (Windows)
5.Install Flask
# macOS/Linux
pip3 install flask
# Windows
pip install flask
6. Ensure Pylint is installed within this virtual environment
pip install pylint
7. Set your python path like this to your env path like this:
{
"python.pythonPath": "/path/to/your/venv/bin/python",
}
Answered By - Mahsa Hassankashi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.