how to make vs code read python imports without displaying yellow squigglies?

  • Last Update :
  • Techknowledgy :

Then I'm assuming you have the vs code python extension installed. In which case, in your project root set a .env file containing the python project root (not necessarily the same thing). Eg. my python code is under src in the project root, so I have in my env file:

PYTHONPATH = "./src/project/"

Then in your settings you can set :

"python.envFile": "${workspaceFolder}\\<project>.env",

this is the solution that I found. in .vscode/settings.json

{
   "python.analysis.extraPaths": ["${workspaceRoot}/path/to/file"]
}

Suggestion : 2

Couple of things, you don't need from anycodings_python-3.x __init__ to import, you can just use anycodings_python-3.x from animals import bird, reptile once anycodings_python-3.x you have the __init__.py file set up. ,I've fiddled with a problem, and have not anycodings_python been able to find a solution. VS Code will anycodings_python not recognize module imports, and thus put a anycodings_python yellow squiggly line under the functions, anycodings_python like this:,Note: Same error with init.py in the anycodings_python animals/ directory.,These are on every function that imports, anycodings_python but it renders and executes perfectly fine anycodings_python when the main file is executed. The issue is anycodings_python solely in the visualization of the code anycodings_python within VS Code.

init.py

from animals.bird
import *
from animals.reptile
import *

app.py

from __init__
import *
print_bird()
print_reptile()

animals/reptile.py

def print_reptile():
   print("I'm a reptile. ssssssssss!")

And when running python3 app.py or python anycodings_python app.py the result is always the expected anycodings_python text of:

I 'm a bird. tweet!
I 'm a reptile. ssssssssss!

Then I'm assuming you have the vs code anycodings_python-3.x python extension installed. In which anycodings_python-3.x case, in your project root set a .env anycodings_python-3.x file containing the python project root anycodings_python-3.x (not necessarily the same thing). Eg. my anycodings_python-3.x python code is under src in the project anycodings_python-3.x root, so I have in my env file:

PYTHONPATH = "./src/project/"

Then in your settings you can set :

"python.envFile": "${workspaceFolder}\\<project>.env",

this is the solution that I found. in anycodings_python-3.x .vscode/settings.json

{
   "python.analysis.extraPaths": ["${workspaceRoot}/path/to/file"]
}

Suggestion : 3

Note: By default, the Black formatter can't be installed when a Python 2 environment is active. Attempting to do so may display the message "Formatter black is not installed. Install?". If you try to install Black in response, another message appears saying "Could not find a version that satisfies the requirement black' No matching distribution found for black.",To enable IntelliSense for packages that are installed in other, non-standard locations, add those locations to the python.autoComplete.extraPaths collection in the settings file (the default collection is empty). For example, you might have installed Google App Engine installed in custom locations, specified in app.yaml if you use Flask. In this case, you'd specify those locations as follows:,Autocomplete and IntelliSense are provided for all files within the current working folder. They're also available for Python packages that are installed in standard locations.,IntelliSense is a general term for code editing features that relate to code completion. Take a moment to look at the example below. When print is typed, notice how IntelliSense populates auto-completion options. The user is also given a list of options when they begin to type the variable named, greeting.

Windows:

"python.autoComplete.extraPaths": [
   "C:/Program Files (x86)/Google/google_appengine",
   "C:/Program Files (x86)/Google/google_appengine/lib/flask-0.12"
]

macOS/Linux:

"python.autoComplete.extraPaths": [
   "~/.local/lib/Google/google_appengine",
   "~/.local/lib/Google/google_appengine/lib/flask-0.12"
]

When using custom arguments, each top-level element of an argument string that's separated by space on the command line must be a separate item in the args list. For example:

"python.formatting.autopep8Args": ["--max-line-length", "120", "--experimental"],
"python.formatting.yapfArgs": ["--style", "{based_on_style: chromium, indent_width: 20}"],
"python.formatting.blackArgs": ["--line-length", "100"]