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
3.Solution
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:
- How to Solve Centos Yum Error: No module named yum
- The _imaging C module is not installed
- [Solved] Jenkins Run python Project Error: “ModuleNotFoundError: No module named ‘xxx‘”
- [Solved] Nodejs Error: Cannot find module ‘express’
- [Solved] ImportError:attempted relative import with no known parent package
- Jenkins – mvn: command not found
- [Solved] NPM installation error: error: eacces: permission denied
- ModuleNotFoundError No module named urllib2
- Pytest executes the case.py file on the terminal error: Modulenotfounderror: no module named ‘API’
- The problem of: modulenotfoundererror: no module named ‘pyqt5’ appears in pychar using pyqt5