Importerror: no module named * [How to Solve]

1. Question

After switching the project from pycharm to sublime text, it is found that a * Py file, the module cannot be found.

2. Cause

When you start the interpreter in the IDE, the current working directory is the project directory, which can successfully call the modules in the same project; However, when you start from the command line, the current working directory is the directory where you started the interpreter. If the current location is not the project directory, the modules in the project directory will not be found. Therefore, an error is reported when running: modulenotfounderror: no module named


Method 1: put the module path into the environment variable as a global variable

Method 2: Add sys.path.append (project directory) at the beginning of the running file

Similar Posts: