PyDev does not recognize imports

2020-02-14 10:43发布

问题:

I am using PyDev for Eclipse, and shows a few red underlines as erros for wrong imports. However, these imports work. I can start the script with F9, and use the Classes from these modules just fine. The red line is bothering me however, plus I cannot use the autocomplete for these imports. How can I force Eclipse PyDev to reevaluate the modules in the project?

I already refreshed my PYTHONPATH with python27/site_packages in it.

Example of red underlines under correct imports:

The module PerClustering.py exists:

The module PerClustering.py contains a class PerClustering:

The other imports do not show red lines. These modules are however in the same directories (or actually namespaces, since the directories contain an empty __init__.py file).

回答1:

Assuming this code works elsewhere and the directory is in tact, you probably just have to rebuild which is pretty common with eclipse projects. To achieve this, navigate to the rebuild option under Project >> Clean.

EDIT: It is unlikely, but you may have to restart eclipse in order to make it work.