/ Published in: Python
When you want to import a python file but that file is not in the same directory as the python file you're importing from (e.g. it's in a subdir). You need to add the directory that contains the file you want to import to your path environment variable sys.path. sys.path contains all the places python will look for a file when you do an import.
Expand |
Embed | Plain Text
import sys sys.path.append('./markdown-1.7') from markdown import Markdown
Comments
Subscribe to comments
You need to login to post a comment.

If you want to ensure that the module you are targeting is imported and not any other module on the PYTHONPATH with the same name, add the directory to the start of the sys.path list with