A solution to "ModuleNotFoundError: No module named XXX" in VSCode

The situation considered here is only for user "custom" python packages, not those that can be installed through pip (such as numpy)

Add before the erroneous import code:

import sys
sys.path.append('./')

# 之后是出现import错误的代码
# import ModuleXXX

One possible reason for this error is that there is a problem with the default python interpreter path of vscode, which makes it impossible to search for custom module packages under the user's working path.

Guess you like

Origin blog.csdn.net/qq_40714949/article/details/129546647