ModuleNotFoundError: No module named 'settings_sensitive'

576 Views Asked by At

I am getting error

ModuleNotFoundError: No module named 'settings_sensitive'

while i was working on a downloaded project where i need to import a file (settings_sensitive.py).

I double checked all the possible errors that could be there.

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 

settings_sensitive = BASE_DIR + '/source/settings_sensitive.py' 
if os.path.isfile(settings_sensitive): 
    from settings_sensitive import *

enter image description here

1

There are 1 best solutions below

3
Naveen On

Try this

import sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
#and then from settings_sensitive import *   or  import settings_sensitive