Visual Studio -- Python 预览错误“无法启动 Python 进程,请验证路径“python””
我正在尝试在一个非常简单的 python 程序(基本打印语句和分配打印的变量)上使用名为“Python Preview”的 VS Code 扩展,并且由于某种原因,每当我尝试使用它时,底部都会弹出一条错误消息屏幕显示:“无法启动 Python 进程,请验证路径“python”。来源:Python Preview(扩展)”。我该如何解决这个问题?我正在 M1 Macbook Air、MacOS Monterey 12.3、Python 3.10.4 64 位、VS Code 版本:1.66.0 上运行(似乎无法在 Mac 上找到此问题的修复程序)。
我尝试过重新启动 Mac 并完全删除并重新安装 VS Code。尝试从这篇文章中做一些解决方案Visual Studio Python“无法启动 Python 进程,请验证路径“python”和错误:生成 python ENOENT 但我无法弄清楚如何在 Mac 上执行它们。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然,问题是由于Python预览扩展不支持Python 3.10。这些是我发现对我有用的唯一步骤:
“在遵循以下步骤之前卸载并重新安装扩展名 -
关闭VSCODE。将以下命令粘贴到
终端
。此命令将访问特定的特定将编辑和修复扩展文件以支持Python的新版本的文件:CD .VSCODE/EXTENSIONS/DONGLI.PYTHON-PREVIEW-0.0.0.4/out/of/debugger/debugclients
接下来,打开LocalDebugClient。 JS文件使用Nano(将此第二个命令键入终端并按Enter):
nano localdebugclient.js
do“ control + v”三次,直到找到以下代码行,
python ' python3 '。终端let pythonpath = 'python'
;接下来, back back back to the第二个文件。扩展名:
cd .vScode/extensions/dongli.python-preview-0.0.0.0.4/out/features
使用nano打开previewmanager.js文件(在
> terminal 然后按Enter):
nano previewmanager.js
do“ control + v”三次,直到找到说:
pythonpath的行:'Python'
(应该是顶部的第三行)。将'python
'更改为'python3
'。执行“控制 + O”并命中返回。然后退出并完全退出终端
现在启动扩展时,应该表明它使用Python3,并且扩展名现在应该使用“
原始答案(这是底部的消息/帖子):( < https:https:// github。 com/dongli0x00/python-preview/6#:〜:text = amoral97,评论%20on%20feb%209 )。无法按预期工作,我没有写它,也无法在下载源时正确编译。最好的好运!”。注意 - 这些命令只会更改扩展名的文件。因此,如果您弄乱了一个步骤,请卸载Python Preview Extension并重新安装它。它不会影响其他任何内容。
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 quitTerminal
Next, open
Terminal
back up to edit the second file. Paste the following command intoTerminal
. 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 quitTerminal
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.
在这方面,您似乎并不完全独自。我确实认为这是一个 PATH 变量问题,但目前我面前没有 Mac 来验证我的假设。不过,这个答案可能会通过将扩展程序指向新的 PATH 路径来帮助您解决问题。然后再参考最后一部分的 Windows 版本。这是我最好的猜测。
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.