尽管我安装了模块,但在 VS 代码中找不到模块错误

编程入门 行业动态 更新时间:2024-10-16 16:02:40
本文介绍了尽管我安装了模块,但在 VS 代码中找不到模块错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用 VS 代码调试一些 Python 代码.我收到有关我确定已安装的模块的以下错误.

I'm trying to debug some python code using VS code. I'm getting the following error about a module that I am sure is installed.

Exception has occurred: ModuleNotFoundError No module named 'SimpleITK' File "C:UsersMidoDesktopProstateX-projectsrc1-preprocessing3_resample_nifti.py", line 8, in <module> import SimpleITK as sitk

我使用

sudo pip install SimpleITK

我知道它已安装,因为我在通过命令行运行代码时遇到了类似的错误,并且通过执行上述操作修复了它.我不明白为什么 VS 代码不能识别

I know that it was installed because I was getting a similar error when I ran the code through the command line, and it was fixed by doing the above. I don't understand why VS code does not recognize that

推荐答案

sudo pip install 很可能全局安装到 Python 解释器中,该解释器与您在 VS Code 中选择的解释器不同.请选择您要使用的 Python 解释器然后使用该解释器显式安装(如果您不使用虚拟环境,则使用类似 /path/to/python -m pip install SimpleITK 之类的东西,尽管我强烈建议使用虚拟环境,不要全局安装包).

sudo pip install is most likely installing globally into a Python interpreter that is different than the one that you have selected in VS Code. Please select the Python interpreter you want to use and then install explicitly using that interpreter (if you're not using a virtual environment then use something like /path/to/python -m pip install SimpleITK, although I strongly recommend using a virtual environment and to not install packages globally).

更多推荐

尽管我安装了模块,但在 VS 代码中找不到模块错误

本文发布于:2023-11-23 19:01:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622539.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模块   但在   管我   中找   错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!