I'm trying to use os.chdir() to change the working directory, and then import a file from that directory.
My code is
import os
os.chdir('./pythonfiles/')
from m269_db import show
show('''SELECT *
FROM student;''')
However, for some reason the response I'm getting is
ModuleNotFoundError: No module named 'm269_db'
Using the print(os.getcwd()) command I get this response:
C:\Users\God\Desktop\unistuff\m269_u6
That is the correct directory. m269_u6 contains the m269_db.py file that otherwise works fine.
I can circumvent this by simply placing the files in the current directory but I can't seem to understand why I can't seem to import the files as I would expect to.