vscode错误:'命令python导致错误(comand' python.setInterpreter&qust of diss of找到)
我开始在Visual Studio代码上使用VENV,当我尝试使用PANDAS时,导入Pandas
它给了我这个错误
“导入“ pandas”无法从源头解决”
因此我尝试使用ctrl+shift+p
在VSCODE中更改Python解释器,我会得到此错误
“命令python导致错误(找不到Comand'python.setInterpreter')。
I started using venvs on Visual Studio Code, and when I am trying to use pandas, by import pandas
it gives me this error
"Import "pandas" could not be resolved from source"
So I tried to use ctrl+shift+p
to change python interpreter in vscode, I get this error
"Command Python resulted in an error (comand 'python.setInterpreter' not found).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
对我来说,从受限模式切换到受信任窗口模式是有效的。
只需点击底部的受限窗口,然后在弹出的窗口中选择“信任”即可。
https://code.visualstudio.com/docs/editor/workspace-trust#_extensions
For me, shifting from restricted mode to trusted window mode worked.
Just click on the restricted window on the bottom and just select "Trust" in the pop up window.
https://code.visualstudio.com/docs/editor/workspace-trust#_extensions
就我而言,我通过单击VSCODE左侧栏中的“扩展”按钮和“ Reload” Python来解决它。 (它将在Python块的左下角显示一个蓝色的重载按钮,只需单击它)
它对我有用!
In my case, I solve it by clicking the "Extensions" button in the left sidebar of VSCode and "Reload" python. (which will show a blue reload button in the lower left corner of Python's block, just click it)
It works for me!!
就我而言,我只是重新安装来自微软的 python 扩展,然后重新加载 vscode。
In my case, i just reinstall the python extension from microsoft then reload the vscode.
我建议两种解决此问题的方法,首先卸载并重新安装扩展名。在Linux(我相信MacOS)上,删除
〜/.vscode/extensions/
,然后手动重新安装将有所帮助。如果那不起作用,您可以尝试手动设置Python解释器(请参阅:有关手动指定解释器的VSCODE文档)。有关更多信息,建议您浏览如何开始在Visual Studio Code中进行调试Python 3.6?
I suggest 2 ways to fix this, first uninstalling and reinstalling the extensions. On Linux (and MacOS I believe), deleting
~/.vscode/extensions/
and then manually reinstalling will help. If that does not work you can try manually setting the python interpreter (see: vscode documentation on manually specifying an interpreter).For more information, I recommend you to look through How to start debugging Python 3.6 in Visual Studio Code?
我可以通过在 vscode 的 settings.json 中添加以下详细信息来解决此问题。
"python.venvFolders" : <您的 venv 文件夹>
"python.venvPath" : <您的 Python 路径>
I was able to fix this issue by adding below details in settings.json of vscode.
"python.venvFolders" : <Your venv folders>
"python.venvPath" : <Your Python path>
就我而言,这发生在USIG远程SSH扩展程序并在远程服务器上进行Python开发时。该问题是由损坏服务器上任何应用程序的DataDog代理。
In my case this happened when usig Remote SSH extension and doing Python development on a remote server. The issue was caused by Datadog agent that corrupted any application on the server.
就我而言,上述解决方案均无效。
我更新了 VS 代码并重新加载了窗口,这解决了问题。
当前 VS code 版本为
1.85.2
。In my case, none of the above described solutions worked.
I updated the VS code and reloaded the window and that resolved the issue.
Current VS code version is
1.85.2
.我遇到了一些错误的问题 - 事实证明,默认情况下,MS Python扩展程序设置为预发行版本(V2024.21.2024112701);我使用可用按钮切换到发行版。
此后,Python文件协会重新建立了自己,并且我的Conda环境得到了认可。
PS还降级了Python调试器,以避免在使用CTRL + F5运行代码时提示调试器。
I had some issues with the same error - it turned out that the MS Python extension was set by default to a pre-release version (v2024.21.2024112701); I switched to the Release Version using the available button.
After this the Python file association re-established itself and my conda environments were recognised.
PS Also downgrade the python debugger to avoid being prompted for a debugger when running code with CTRL + F5.