astral-sh / ruff-vscode

A Visual Studio Code extension with support for the Ruff linter.
Other
945 stars 45 forks source link

VSCode Ruff doesn't work: Python interpreter missing: #493

Closed SUPERustam closed 3 weeks ago

SUPERustam commented 3 weeks ago

I installed latest version of python, vs code and ruff (also ruff-lsp in my .env), but get error and can't format code in jupyter files/python files. image

My system:

  1. Apple Silicon chip
  2. MacOS Sonoma 14.5
  3. VSCode 1.90.0
  4. Python 3.12.3
  5. Extension: Realise 2024-06-05, 21:28:08
  6. Ruff 0.4.8, ruff-lsp 0.0.53
zanieb commented 3 weeks ago

Hi! ruff-lsp requires Python to be installed on your system. You'll need to configure VSCode to use a Python interpreter as described in the error message.

I'm not sure why it's not finding the Python installation you have. Could you share more details about where your Python is installed? i.e.which python? What happens if you configure it directly?

~Alternatively, our new server does not require a Python interpreter.~ @charliermarsh has pointed out this isn't true until #479

SUPERustam commented 3 weeks ago

I already have Python on my machine, these my python interpreters:

  1. /usr/bin/python3 (3.9)
  2. /opt/homebrew/bin/python3 (3.12.3)

I have ~/.vscode/extensions/ms-python.python-2024.8.0, but it doesn't work and I don't know where to find the right ms-python.python (it's weird because I am on Mac not on Windows)&

I don't change any settings of ruff extenstion. This's my default package.json in ~/.vscode/extensions/charliermarsh.ruff-2024.26.0-darwin-arm64 package.json

Previously, before latests updates of extension (or vscode? ) all my ruff staff work fine on this machine. I don't even change settings of vscode-ruff, all work perfectly fine out of the box.

charliermarsh commented 3 weeks ago

To clarify, I believe ms-python.python is the VS Code Python extension, not Python itself. So it's required regardless of operating system.

charliermarsh commented 3 weeks ago

I'm just looking through the history to see if we changed anything related to this and I'm not seeing anything relevant.

charliermarsh commented 3 weeks ago

Do you have a Python interpreter configured in the VS Code window? E.g., in the bottom right here?

Screenshot 2024-06-08 at 4 35 08 PM

SUPERustam commented 3 weeks ago

Thank you, @charliermarsh and @zanieb!!! Yes, VS Code didn't recognize my interpreter, but after setting it, everything immediately started working fine.