Python terminal execution program error: ModuleNotFoundError: No module named'*******'

 

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:

 

Guess you like

Origin blog.csdn.net/u013282737/article/details/85124979