Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialvinay kumar
147 PointsError executing python file
treehouse:~/workspace/learning_site/courses$ python views.py
Traceback (most recent call last):
File "views.py", line 4, in <module>
from .models import Course
SystemError: Parent module '' not loaded, cannot perform relative import
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsGreat question! The "parent module" is the top most module in the execution hierarchy. In Python, this top-most level is given the name __main__
. This make relative imports not possible at the top level.
In the docs on intra-package references, it says
Note that relative imports are based on the name of the current module. Since the name of the main module is always "__main__", modules intended for use as the main module of a Python application must always use absolute imports.
Post back if you need more help. Good luck!!!