Hi guys, I have a simple question.

I'm trying to import my modules from a different folder (the different folder is in the same place as the the program I'm importing from), but I don't know how. I've looked on Google, but I've had no luck so far.

My question is: How does one import a module from another folder?

If your module is in folder c:\Python25\myFolder then you can tell Python to look there by appending PYTHONPATH ...

# appends to PYTHONPATH  the location of your custom module folder
# use this in the beginning of your program
import sys
sys.path.append(r"c:\Python25\myFolder")

To see the folders where Python normally looks at ...

import sys
print sys.path

Ah, ok! That worked wonders! Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.