When I write import MySQLdb
in Eclipse using the PyDev plugin, I get an unresolved import. However, the program runs without error. I can add an annotation to get the error to go away, but what is the right way to handle this?
How can I help Eclipse know that MySQLdb is there?
It sounds like MySQLdb
is somewhere on your sys.path
, but not on your Eclipse project's PYTHONPATH
; in other words, Eclipse thinks you're going to get an import error at runtime because you haven't fully configured it. Google seems to say that you can alter this setting in Window->Preferences->Preferences->PyDev->Python Interpreter
to include the path to your MySQLdb
module.
For some help figuring out where MySQLdb
might be living on your system:
import MySQLdb
print MySQLdb.__file__
; it may be the __init__
file in the package that you need to point the path at.cdleary above provided the reason two years ago, but this may be easier. Basically, one reinstalls the interpreter.
This works on Fedora 17 using the Eclipse 4.2.0 that came with the package management.
Fixed this by doing two things:
1) Added MySQLdb egg to the PYTHONPATH under Window->Preferences->Preferences->PyDev->Python Interpreter.
C:\Python26\Lib\site-packages\MySQL_python-1.2.3c1-py2.6-win32.egg
2) Close and re-open the .py file that had the red x.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With