How do I handle an UnresolvedImport Eclipse (Python)

后端 未结 8 2415
悲&欢浪女
悲&欢浪女 2021-02-20 04:41

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

8条回答
  •  孤街浪徒
    2021-02-20 05:28

    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:

    1. Open an interactive interpreter,
    2. import MySQLdb
    3. If that succeeds, you can get a hint from: print MySQLdb.__file__; it may be the __init__ file in the package that you need to point the path at.

提交回复
热议问题