Ben Chuanlong Du's Blog

It is never too late to learn.

ImportError: Attempted Relative Import With No Known Parent Package

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Symptom

ImportError: Attempted Relative Import With No Known Parent Package

Solution

The best solution is to run the Python script as a Python module. However, you have to add the directory …