Just add as follows:
import sys
import os
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath)
For example, it turned out to be:
After adding:
You can execute the python server.py command successfully in the terminal, otherwise an error will be reported as follows: