英文:
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.
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.
答案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.
You can add the following configuration to settings.json to specify the default interpreter, and then select it in the Select Interpreter panel
"python.defaultInterpreterPath": "E:\\workspace\\py12\\.venv\\Scripts\\python.exe",
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论