Chris
Chris

Reputation: 361

Importing a python module from another directory

The below is what my folder for my project looks like. The code itself relies on the files that are contained within the Project folder - so my question is simple.

What is the simplest way to use import Maths from a differant directory? I have gotten it to work before, but it never loads the files as well.

Project (Main Folder):

resources
    bg.png
    student.png
    stylesheet.css
    template.html

configFile.pickle
Maths.pyw
userKeycodes.pickle

Upvotes: 0

Views: 63

Answers (1)

Arkadiusz Tymieniecki
Arkadiusz Tymieniecki

Reputation: 116

add project folder to sys.path

import sys
sys.path.append('/project/folder')
import Maths

Upvotes: 2

Related Questions