0

I am trying to use a VS Code Extension called "Python Preview" on a very simple python program (basic print statements and assigning variables that are printed) and for some reason, whenever I try to use it an error message pops up at the bottom of the screen: "Failed to launch the Python Process, please validate the path 'python'. Source: Python Preview (Extension)". How do i fix this? I am running on a M1 Macbook air, MacOS Monterey 12.3, Python 3.10.4 64-bit, VS Code Version: 1.66.0 (can't seem to find a fix for this problem on Mac).

I have tried restarting my Mac and completely deleting and re-installing VS Code. Tried to do some solutions from this post Visual Studio Python "Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT but I wasn't able to figure out how to do them on Mac.

nitind
  • 19,089
  • 4
  • 34
  • 43
mpp
  • 308
  • 1
  • 14

2 Answers2

1

Apparently the issue is due to the Python Preview extension not supporting Python 3.10. These were the only steps I was able to find that worked for me:

"Uninstall and reinstall the extension before following these steps--

Close VScode. Paste the following command into Terminal. This command will access a specific file which will edit and fix the extension file to support new versions of Python: cd .vscode/extensions/dongli.python-preview-0.0.4/out/debugger/debugClients

Next, open the localDebugClient.js file using nano (type this second command into Terminal and press Enter): nano localDebugClient.js

Do "Control + v" three times until you find the following line of code, let pythonPath = 'python'; Change 'python' to 'python3'. Then do "Control + o" and hit Return. Then exit and fully quit Terminal

Next, open Terminal back up to edit the second file. Paste the following command into Terminal. This command will access a specific file which will edit and fix the extension: cd .vscode/extensions/dongli.python-preview-0.0.4/out/features

Open the previewManager.js file using nano (type this second command into Terminal and press Enter): nano previewManager.js

Do "Control + v" three times until you find the line that says: pythonPath: 'python' (it should be the 3rd line from the top). Change 'python' to 'python3'. Do "Control + o" and hit Return. Then exit and fully quit Terminal

Now when you launch the extension it should show that its using python3 and the extension should work now"

Original Answer (it's the message/post at the very bottom): (https://github.com/dongli0x00/python-preview/issues/6#:~:text=amoral97,commented%20on%20Feb%209). The user who posted this answer also said "This extension was not made for python3 and might not work as intended for it, and I did not write it nor could I get it to compile correctly when I downloaded the source. Best of luck!". NOTE - These commands only change the files for the extension. So if you mess up a step, uninstall Python Preview extension and re-install it. It doesn't affect anything else.

mpp
  • 308
  • 1
  • 14
0

It seems you're not exactly alone in this regard. I do think it is a PATH variable issue, but I do not have a Mac in front of me at the moment in order to test my hypothesis out myself. Still, this answer might help you solve the issue by pointing the extension to the new PATH's path. Then refer back to the Windows version for the last part. This would be my best guess.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 02 '22 at 03:08
  • I was able to find the answer. I was wrong and apparently the issue had nothing to do with PATH or Python, but instead the issue was the Python Preview extension does not support Python 3.10. – mpp Apr 02 '22 at 04:37