How to import modules from different folders? I have the following
cgi-bin
| py
|
__init.py__
http
|
__init.py__
HttpFormParser.py
xml
|
__init.py__
XmlDocumentCreator.py
I want to import XmlDocumentCreator in HttpFormParser.py. How to do that ?
I’m doing
import py.xml.XmlDocumentCreator
in HttpFormParser.py and its throwing the following error.
/HttpFormParser.py", line 5, in <module>
import py.xml.XmlDocumentCreator
ImportError: No module named py.xml.XmlDocumentCreator
Just work out the directory you’re executing from, as told by
sys.argv[0]. In this case, you want to get thecgi-bindirectory since it containspy:P.S. if you’re using WSGI, you don’t need your Python code in a
cgi-bindirectory, where it could be downloaded if your.htaccess(or equivalent) is set wrong.