Home > Blockchain >  Visual Studio -- Python Preview Error "Failed to launch the Python Process, please validate the
Visual Studio -- Python Preview Error "Failed to launch the Python Process, please validate the

Time:04-02

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.

CodePudding user response:

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.

CodePudding user response:

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 the following 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 on Feb 9). 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.

  • Related