From XXX import * error in Jupyter

Importing modules in Jupyter will appear from XXX import * 报错

But XXX.py is indeed in the same directory, but the XX method in XXX cannot be imported.

The solution to the problem is: Please add

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

By executing the line sys.path.append('./') you add the current directory (that is, './') to sys.path. This means that the Python program will look for modules in the current directory so that it can correctly import the module files in the current directory.

This is useful in some cases, especially when your Python script or program needs to import a custom module in the same directory. By adding the current directory to sys.path, you ensure that Python can find and correctly import modules in the current directory.

Guess you like

Origin blog.csdn.net/weixin_44510615/article/details/132651611