Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

141
Views
Import could not be resolved/could not be resolved from source Pylance in VS Code using Python 3.9.2 on Windows 10 Powershell

My Flask App server is running but I have three imports that cannot be resolved. unresolved imports

I have tried:

  1. reinstalling the imports individually
  2. reinstalling requirements.txt
  3. I configured VSCode Workspace with an extra path to my project folder (there is now a .vscode file within the root of my project folder where it was not before)
  4. I have updated my venv path settings in VSCode

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?

10 months ago · Santiago Trujillo
3 answers
Answer question

0

1.Open Command Palette, then select the Python: Select Interpreter command. From the list, select the virtual environment in your project folder that starts with .env.

2.Run Terminal: Create New Integrated Terminal (Ctrl+Shift+`)) from the Command Palette, which creates a terminal and automatically activates the virtual environment by running its activation script.

3.Install sqlalchemy and mongoengine with command pip install. Once installing them successfully, there will intellisense when you import them and no warnings shown.

enter image description here

Besides, the folder .vscode is to store Workspace settings as well as debugging and task configurations.

10 months ago · Santiago Trujillo Report

0

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

10 months ago · Santiago Trujillo Report

0

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.

  1. (Ctrl+Shift+P) then search for "Python: Select Interpreter"
  2. Click "Enter interpreter path" followed by "Find.."
  3. Navigate to your project virtual environment folder
  4. Go into "Scripts" folder and then select "python.exe" as the interpreter.

These steps allow you to select the right python interpreter associated with the project's virtual environment.

10 months ago · Santiago Trujillo Report
Answer question
Find remote jobs