'No module named' error in Python while importing outside /home directory
Probably this is a silly issue, but I haven't been able to figure it out.
I'm getting ImportError: No module named etree.ElementTree
when I write:
#!/usr/bin/python3.2
import xml.etree.ElementTree as etree
tree = etree.parse('feed.xml')
root = tree.getroot()
If I run this same script in /home/
or /home/<user>/
, it works fine but when my current working directory is /home/<user>/<some_directory>/<some_subdirectory>
, I get the above mentioned error.
What is happening here?
Additional info: I'm running Ubuntu 11.04 and Pyt开发者_运维知识库hon 3.2
Thanks in advance.
Try running Python in the place where it works and the place where it doesn't work, and compare the values of sys.path
when running Python in those two locations.
My first guess would be that you have $PYTHONSTARTUP
set to something that depends on the working directory.
精彩评论