Skip to content Skip to sidebar Skip to footer

No Module Named Fitness Python Import Error

i'm having troubles with python importing. Here is my structure. fitness/ __init__.py authentication/ __init__.py views.py urls.py views.py

Solution 1:

You need to add the directory containing the module you're trying to import (fitness.views) to the PYTHONPATH. Put this at the beginning of your module. It adds '../../' to the PYTHONPATH. That is the directory containing the fitness folder, so you can import the module without any problem.

import sys, os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
from fitness import views

Post a Comment for "No Module Named Fitness Python Import Error"