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 containing the Python module into the Python module search path first. A simple way to do this is to define the PYTHONPATH environemnt variable.

PYTHONPATH=/root/xinstall/ python3 -m xinstall.main -h

References

ImportError: Attempted Relative Import With No Known Parent Package (Python)

Comments