Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 vscode 并使用 pylance 在 python 中进行 linting 尝试导入 restframework 时出现错误:
Import "rest_framework.decorators" could not be resolved
当我选择 conda 环境作为我的 python 解释器时出现此错误,但如果我选择默认 python 路径作为我的解释器,我不会收到此错误。
为什么只有当我选择 conda 环境作为解释器路径时才会出现此类错误
请通过回答帮助我。
您必须将要导入的软件包安装在您选择的环境中。从上面看,听起来你已经将它安装在全局 Python 环境中,但没有安装在你的 conda 环境中。尝试选择您的 conda 环境,然后在 Visual Studio Code 中打开一个终端窗格并“conda install”包并查看是否有帮助(尽管您可能需要重新加载编辑器或切换回环境以获取更改)。