Solve the problem of error when importing module under PyCharm directory
- 2020-12-16 06:00:33
- OfStack
In PyCharm2017, No model named... Error, but can actually run
This is because PyCharm does not automatically add the current file directory to source_path.
Right-click make_directory as-- in the current directory > Sources Root
python import module
Import b.py from a.py in the same directory as a.py
import b or from b import method/function
Import b.py under different directories in a.py
import sys
sys.path.append (' Absolute path to b module ')
import b