Skip to content
Advertisement

Visual Studio Code not recognizing Python import and functions

What do the squiggly lines represent in the image?

The actual error the flags up when I hover my mouse over the squiggly line is:

Import “pyspark.sql.functions” could not be resolvedPylance

I’m not sure what that means, but I’m getting the error for almost all functions in Visual Studio Code.

How can I resolve it?

Enter image description here

Enter image description here

Enter image description here

Enter image description here

Advertisement

Answer

I was with the same error as yours. Visual Studio Code usually has a “recommended” interpreter, but sometimes it won’t help you out with what you need. So,

  1. I changed the Interpreter (Ctrl + Shift + P in Visual Studio Code).
  2. Look for “Python: Select Interpreter.
  3. Choose the one who contains the name “Conda”

And that’s how the magic happens.

Advertisement