No module named and Attempted relative import : The Import Mechanism Of Python And Two Related Problems

allianzcortex profile image Allianzcortex ・1 min read

No module named

Issue Description :

This problem ever happened when the application was executed with the command line, but it can be executed smoothly with the Pycharm run button. So it can be very simple to debug, just check the show command line afterwards in the edit configuration item of Pycharm, and then execute the import sys; sys.path command. Compare the options in the command line,you will find the former has Added a module for /home/hzcortex/projects.... In other words, Python does not add the directory where the script executes the command to sys.path.


Editor guide