Python3 and VSCode ModuleNotFoundError: No module named ‘_ctypes’

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

Python3 and VSCode ModuleNotFoundError: No module named '_ctypes'

问题

I'm working with Visual Code and Python 3 and am getting a

ModuleNotFoundError: No module named '_ctypes' error.
error on my laptop. (A similar setup works on my desktop)

It turns out that VS code is pointing to a python version installed by chocolatey.

I was able to fix it by changing to a different local python installation Following this
https://stackoverflow.com/questions/56658553/module-not-found-error-in-vs-code-despite-the-fact-that-i-installed-it

but the next time I restarted VS Code the problem returned.
Can I either make VS Code keep using the new installation, or otherwise fix the chocolatey installation?

(the problem with chocolatey python may be related to this question, but I'm not sure how to fix it in chocolatey)
https://stackoverflow.com/questions/27022373/python3-importerror-no-module-named-ctypes-when-using-value-from-module-mul

I would love some help with either one of these directions.

英文:

I'm working with Visual Code and Python 3 and am getting a

> ModuleNotFoundError: No module named '_ctypes' error.

error on my laptop. ( A similar setup works on my desktop )

It turns out that VS code is pointing to a python version installed by chocolatey.

I was able to fix it by changing to a different local python installation Following this
https://stackoverflow.com/questions/56658553/module-not-found-error-in-vs-code-despite-the-fact-that-i-installed-it

but the next time I restarted VS Code the problem returned.
Can I either make VS Code keep using the new installation, or otherwise fix the chocolatey installation?

( the problem with chocolatey python may be related to this question, but I'm not sure how to fix it in chocolatey )
https://stackoverflow.com/questions/27022373/python3-importerror-no-module-named-ctypes-when-using-value-from-module-mul

I would love some help with either one of these directions.

答案1

得分: 1

尝试通过点击右下角的图章,以切换解释器,并选择所需的Python版本。

如果除了Chocolatey版本之外什么都没有,请尝试手动定位您想要使用的版本,例如点击加号图标并导航到Python文件夹。

英文:

Try to swap interpreter by clicking on the bottom right corner as in the stamp below and select the desired python version.

Python3 and VSCode ModuleNotFoundError: No module named ‘_ctypes’

If nothing besides the chocolatey one appears, try to manually locate the one you want to use like clicking on the plus icon and navigating to the python folder.

Python3 and VSCode ModuleNotFoundError: No module named ‘_ctypes’

答案2

得分: 1

选择适用于你的 Python 扩展的正确解释器(<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> --> Python:Select Interpreter)。

使用官方扩展 Python 来执行脚本。

你可以将以下配置添加到 settings.json 中,以指定默认解释器,然后在 选择解释器 面板中选择它。

	"python.defaultInterpreterPath": "E:\\workspace\\py12\\.venv\\Scripts\\python.exe",
英文:

Choose the correct interpreter for your python extension (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> --> Python:Select Interpreter).

Execute scripts using the official extension Python.

Python3 and VSCode ModuleNotFoundError: No module named ‘_ctypes’

You can add the following configuration to settings.json to specify the default interpreter, and then select it in the Select Interpreter panel

	&quot;python.defaultInterpreterPath&quot;: &quot;E:\\workspace\\py12\\.venv\\Scripts\\python.exe&quot;,

Python3 and VSCode ModuleNotFoundError: No module named ‘_ctypes’

huangapple
  • 本文由 发表于 2023年4月13日 23:21:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76007207.html
匿名

发表评论

匿名网友

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

确定