Python Forum

Full Version: How to import another Python in different directory?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I would like to get help on importing another Python program in different directory. I didn't seem finding that is straight forward from googling.
Thanks.
I figured it out. Thanks.

Sorry. I don't know how to delete the post.
Instead of deleting the post, post your answer to the question. There might be a better way to solve this problem, or somebody else might have the same problem and would benefit from reading your solution.
Added the directory where the Python program is located to the sys.path, then import the Python program.

import sys
file_dir = "c:\\Users\\dee\\Documents\\_Python"
sys.path.append( file_dir )
import Connection as conn