PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 28, 2022

[FIXED] How to resolve VSCode import warnings with python scripts?

 April 28, 2022     python, visual-studio-code, warnings     No comments   

Issue

VSCode gives a warning whenever I import a python file from the same directory, but in practice everything works fine when the scripts run.

In a sample directory:

root_folder
+-- __init__.py (empty)
+-- __main__.py (empty)
+-- __import.py (contains Parent class)
+-- toImport.py (contains Child(Parent) class)

I try the following in toImport.py:

from __import import Parent

class Child(Parent): ...

Although I keep getting a warning: unresolved import even if it works. How can I resolve this issue or is it a VSCode issue?


Solution

Add this to your projects .vscode/settings.json file.

{
  "python.autoComplete.extraPaths": ["./root_folder"]
}


Answered By - GollyJer
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing