Python解释器在VS Code中显示的不应存在。

huangapple go评论82阅读模式
英文:

Python interpreter that should not exist shown in VS Code

问题

我是一个使用 Zorin OS 发行版的 Linux 用户,使用 Visual Studio Code 的 Flatpak 版本。
我已经下载了必要的扩展(Python 和 Pylance)。

我已经选择了我的解释器,但有一些事情让我感到困扰。

如你所见,我有 4 个可用的解释器,但首先,我的 Python 版本是 3.8.10,而不是 3.10.11,其次,第二和第四个解释器不起作用,因为文件不存在。
另一件事,如果我在终端中输入 which python,结果是 usr/bin/python,但这里推荐的解释器是 bin/python

我的问题是:

  1. 为什么有不存在的解释器?我可以删除它们吗?

  2. 为什么版本不匹配?我需要配置什么吗?

  3. 为什么推荐的解释器与我操作系统使用的不同?有什么区别吗?

英文:

I'm a linux user (zorin-os distro) using the flatpak version of Visual Studio Code.
I have downloaded the necessary extensions (Python and Pylance).

I have selected my interpreter but there is something bothering me.

Python解释器在VS Code中显示的不应存在。

As you can see I have 4 interpreters available but firstly, my version of python is 3.8.10 and NOT 3.10.11 and secondly, the 2nd and 4th interpreter does not work because the file does not exist.
Another thing, if I type which python in the shell then the result is usr/bin/python but here the recommanded interpreter is bin/python.

My questions are:

  1. Why are there interpreters that do not exist? Can I remove them?

  2. Why the version mismatch? Do I have to configure something?

  3. Why is the recommanded interpreter not the same as the one used by my os? Is there any difference?

答案1

得分: 1

问题已经自行解决。
我不知道是怎么解决的,但我可能有一个想法。
正如我在与@JialeDu的对话中所说(请参见上文),我的Python VSCode解释器位于/var/lib/flatpak/runtime/org.freedesktop.Sdk/x86_64/22.08/ac3b29f9b04246d2b346de5632914232ee9c511702fc3c4e0d1c125a6de1e3ca/files/bin,而文件夹"22.08"让我觉得它需要ubuntu-22才能正常运行(在zorin-os 16.3之前没有)。

所以,如果你使用的是zorin发行版,也许更新到最新版本可以解决你的问题。

祝你有个愉快的一天!

英文:

The problem was solved on its own.
I don't know how but I may have an idea.

As I said in my conversation with @JialeDu (see above), my python vscode interpreters are located at /var/lib/flatpak/runtime/org.freedesktop.Sdk/x86_64/22.08/ac3b29f9b04246d2b346de5632914232ee9c511702fc3c4e0d1c125a6de1e3ca/files/bin and the folder "22.08" make me think that it needed ubuntu-22 to function properly (which wasn't present in zorin-os before version 16.3).

So if it happens that you're using the distro zorin, maybe updating to the last version available will solve your problem.

Have a nice day !

答案2

得分: 0

> 为什么有些解释器不存在?我可以移除它们吗?

由于缓存等原因,会出现重复或错误的解释器,通常重新启动 vscode 或刷新 选择解释器 面板将会移除它们。

> 为什么版本不匹配?我需要配置什么吗?

不需要,您在 选择解释器 面板中选择的解释器是 Python 扩展使用的解释器。

> 为什么推荐的解释器与我的操作系统中使用的不同?有什么区别吗?

这里解释了扩展将查找解释器的位置,以及它如何为当前工作空间推荐解释器

在 vscode 中选择的解释器仅对 Python 扩展有效。但操作系统中可能存在多个 Python 环境,首选的解释器与您的环境变量 path 相关。

英文:

> Why is there interpreters who does not exist ? Can i remove them ?

There are duplicate or wrong interpreters due to caching etc, usually restarting vscode or refreshing the Select Interpreter panel will remove them.

> Why the version mismatch ? Do I have to configure something ?

No, the interpreter you choose in the Select Interpreter panel is the one used by the Python extension.

> Why the recommanded interpreter is not the same as the one used by my os ? Is there any difference ?

This explains where the extension will look for interpreters and how it will recommend an interpreter for the current workspace.

The interpreter selected in vscode is only valid for Python extensions. But there may be multiple python environments throughout the operating system, and the preferred interpreter will be related to your environment variable path.

huangapple
  • 本文由 发表于 2023年7月28日 03:50:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76782979.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定