How To Fix Unresolved Import Issues In Eclipse PyDev Project

When i use eclipse to open an exist PyDev project, i find error message like Unresolved import: smtplib. This error means the python3 built-in library smtplib can not be found and imported in python source code now. This error is because of the python interpreter is not configured correctly, now i will tell you how to fix it.

eclipse pydev project unresolved import issue

1. How To Change Python Interpreter Correctly In Eclipse PyDev Project.

  1. Open eclipse which has installed PyDev plugin ( How To Run Python In Eclipse With PyDev ).
  2. Click Eclipse —> Preferences… menu item at eclipse left top menu in MacOS. If you use Windows OS, you should click Window —> Preferences menu item.
  3. Click PyDev —> Interpreters —> Python Interpreter menu item at left panel. If you can not see a python interpreter configured at right panel, then just add it. If there has one python interpreter added, maybe this interpreter is not correct, you should change it.
    eclipse - preferences - pydev - interpreters - python interpreter
  4. Click Choose from list button at right panel, then select the python interpreter which you need in the popup dialog, generally we choose the newest python version.
    select python interpreter installation path
  5. Click OK button, then select all the libraries that will be added in the PYTHONPATH system variable.
    select the python libraries to add to python path
  6. Click OK button again, now you can see the python interpreter has been added. Select the python interpreter and click Libraries tab at right panel bottom,  you can see the libraries list that you selected.
  7. Now click Apply and Close button to close the python interpreter configuration panel to apply your changes.

2. How To Make Python Interpreter Change Take Effect.

To make the python interpreter change take effect, you need follow below steps, otherwise the Unresolved Import error still exist.

  1. Right click the PyDev project, then click Delete menu item in the popup menu list.
  2. Click OK button in the popup dialog to delete the project from eclipse. Please do not check Delete project contents on disk checkbox.
    delete eclipse project confirm dialog
  3. Click eclipse menu item File —> Open Projects from File Systems….
    eclipse file - open projects from file system
  4. Click Directory… button and browse the exist PyDev project saved directory.
    select exist pydev project directory in the eclipse popup dialog window
  5. Click Finish button to complete the PyDev project import. Now you can see the error has disappear.
  6. If you want to add third party python libraries into the eclipse PyDev project, you can read article How To Add Python Module Library In Eclipse PyDev
0 0 vote
Article Rating
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x