PyDev does not recognize imports
Asked Answered
F

3

5

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:

Example of red underlines under correct imports

The module PerClustering.py exists:

The module PerClustering.py exists

The module PerClustering.py contains a class PerClustering:

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).

Force answered 7/10, 2014 at 11:49 Comment(0)
T
3

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.

Tessie answered 7/10, 2014 at 11:55 Comment(2)
A project Clean+Build was not enough, but a subsequent restart of Eclipse seems to do the trick.Force
Really? That is interesting. I never have to restart my IDE after rebuilding but there you go. Hope that helps.Tessie
T
0

The Python interpreter may not be set up correctly.

To correct this, go to Eclipse Preferences > PyDev > Interpreters > Python Interpreter, then select New to add the correct Python interpreter. Finally hit Apply and Close. You may have to re-open the editors.

In my case (macOS), the default was the Python 2 interpreter at /usr/bin/python, and I had to add the Python 3 interpreter from /usr/bin/python3.

Thorley answered 24/11, 2021 at 9:52 Comment(0)
C
0

In my case, after certifying that the directory was added to the PATH, I did not need to restart the Eclipse, I just had to rewrite the from line, so that the IDE recognizes the directory with the intelisense. This is, if the red squiggles are still there.

  • NOTE: The libraries need to be added into External Libraires inside PyDev - PYTHONPATH
Cedillo answered 16/12, 2021 at 17:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.