My Flask App server is running but I have three imports that cannot be resolved.
I have tried:
Here is my file structure:
- > .vscode
- > client *(React front end)*
- > data
- > server *(Python/Flask back end)*
- > app
- > venv
- config.py
- README.md
- requirements.txt *(this contains the 3 unresolved, along with several that are resolving)*
- .env
- .flaskenv
- .gitignore
- requirements.txt
Unfortunately none of these things have resolved my imports issue and my routes are still not working. Any ideas/suggestions?
Open the Command Palette (Ctrl+Shift+P), then select the Python: Select Interpreter. From the list, select the virtual environment in your project folder that starts with .env
.
Run Terminal: Create New Integrated Terminal (Ctrl+Shift+` or from the Command Palette), which creates a terminal and automatically activates the virtual environment by running its activation script.
Install sqlalchemy
and mongoengine
with command pip install
. Once installing them successfully, there will intellisense when you import them and no warnings shown.
Besides, the folder .vscode
is to store Workspace settings as well as debugging and task configurations.
If you are using a virtual environment, and even after trying pip installing all the necessary libraries, you have to select the python interpreter that exists in the virtual environment folder.
These steps allow you to select the right python interpreter associated with the project's virtual environment.
I specified a path to the python interpreter I'm using within the settings.json file contained in the project repo's .vscode folder.
"python.pythonPath": "path-to-interpreter.python.exe"
Thanks to the following resource! https://dev.to/climentea/how-to-solve-pylance-missing-imports-in-vscode-359b
I ran into this error after an upgrade of my local python version (brew -> manual install), even though the specified interpreter was already /usr/local/bin/python3
.
CMD + Shift + P
and re-selecting the [same] interpreter fixed the error.
I suspect that a restart of VSCode may have also fixed this, in the end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With