Forums

Importing File From Parent Directory

Hi, I'm trying to import a file from a parent directory, and I seem to run into trouble whenever I run my code.

This is interesting since my code works when I run it locally, so is there an issue with how I am using it on Pythonanywhere?

├───AGS
│   └───Unit1
|         └───FILE
|   └───FILE TO IMPORT

Code:

import sys; sys.path.insert(0, "..")
from loader import getInt, getFrac, LinFunc, QuadFunc, latexify, signify

Error:

Error running WSGI application
ModuleNotFoundError: No module named 'app.logic.AGS1.Unit1.loader'

Try adding the absolute path of the parent directory to the sys.path.