0

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?

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Azurea
0

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
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.