To solve Import flask could not be resolved from source Pylance error follow below methods.
Import flask could not be resolved from source Pylance
How to solve Import flask could not be resolved from source Pylance ?
I encountered the problem you stated when I did not install the module “flask.” The reason for this is that the “flask” module is not installed in the Python environment that we are currently using in VSCode.
Please use the shortcut key Ctrl+Shift+’ to create a new VSCode terminal, which will automatically enter the currently selected environment, and then run the command “pip show flask” to see where the module “flask” is installed:
If the module still cannot be resolved, it is recommended that you reinstall the module “flask.”
Alternative to Solve Import flask could not be resolved from source Pylance
In case you are using a virtual environment;
- Create a virtual environment.
python3.9 -m venv --without-pip virtual
- Activate the virtual environment.
- Install the pip for the created virtual environment.
curl https://bootstrap.pypa.io/get-pip.py | python
- Install flask into the virtual env.
pip install flask
- Create the python file.
- Open file and import the module
- If it underlines again, install pip again while the .py file is still open.
pip install flask
Other Solutions when using VS Code
- Firstly Create a Virtual Environment on your terminal
- then install your flask by pip install flask
- after install CTRL+SHIFT+P
- Search Python Interpreter
- Select Your virtual Environment\
Other way to solve Import flask could not be resolved from source Pylance
I ran into a similar problem when attempting to import flask into vscode. I corrected it with anaconda. Simply place the flask module in your newly formed environment.
How to make a virtual environment in Anaconda:
- Select Environments from the left sidebar.
- Select Create (at the bottom).
- In the pop-up window, name your vir .env and choose the language version.
- After you’ve constructed it, you may begin installing various modules in your environment.
Hope the above solution works.
Also read :
RuntimeError: cuDNN error: CUDNN_STATUS_NOT_INITIALIZED
WARNING: `pyenv init -` no longer sets PATH. Run `pyenv init` to see the necessary changes to make to your configuration.