4

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Patterson
  • 1,927
  • 1
  • 19
  • 56
  • 1
    Did you select the right Python interpreter? – Klaus D. Dec 15 '21 at 11:12
  • some questions: - does your code actually run without import errors? - do you use virtualenv? - is vscode using the right python version? Do you use the right shebang? https://stackoverflow.com/questions/6908143/should-i-put-shebang-in-python-scripts-and-what-form-should-it-take – Josh Dec 15 '21 at 11:12
  • Klaus, Josh, I'm new to VSCode. Can you let me know how to determine the right Python interpreter? How to instsall right Python version? – Patterson Dec 15 '21 at 11:41
  • 1
    In the blue bottom bar somewhere on the left is the selected Python interpreter. If you have multiple installations you can select the right one there. Of cause you have to install the dependencies of your project for that interpreter version / virtual environment. – Klaus D. Dec 15 '21 at 12:12

2 Answers2

6

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

Also check the Workspaces. If you have two or many workspaces opened (many codebase folders), the editor will be hard pressed to associate the interpreter-linter with the code.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
gdm
  • 7,647
  • 3
  • 41
  • 71