尽管我安装了VS代码,但模块未找到错误 [英] Module not found error in VS code despite the fact that I installed it

查看:84
本文介绍了尽管我安装了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:\Users\Mido\Desktop\ProstateX-project\src\01-preprocessing\03_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最有可能全局安装到与您在VS Code中选择的Python解释器不同的Python解释器中.请选择要使用的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代码,但模块未找到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆