Thursday, August 26, 2010

PyDev unresolved import error!

Yeah, I spent this whole day, figuring out why PyDev cannot import modules of xml packages.
The standard ones like SAX, DOM, eTree, etc.
I almost gave up using PyDev for Python development and was about to go back to Emacs or try something else.
There was nowhere I could find the information on the web.
I did everything I could do in Eclipse Preferences, about Python-Interpreter SYSTEMPATH.
I erased Eclipse IDE and re-downloaded, re-imported the project, etc...

The problem was:
when you have a package in your project with the same name as you want to import from SYSTEMPATH, PyDev starts to load from the package in your project, doesn't look in the SYSTEMPATH, returns error and aborts running.

Sounds obvious?
Well, but when you don't have anywhere saying 'import xml.sax' in your code, and the PyDev returns error that it can't find 'xml.sax' or whatever, because somewhere in some package in your SYSTEMPATH calls 'xml.sax', it becomes a labyrinth.
Just executing it on the shell works fine, but PyDev returns error.

1 comment:

  1. And remember that if you ever compiled that xml.py file there will be a xml.pyc file that has to be deleted before you can get ANYTHING to work!

    ReplyDelete