DEV Community

Allianzcortex
Allianzcortex

Posted on

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

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.

Top comments (0)