1

When I am in certain files, for example, External Library files, I am getting this behavior where the Go To Definition command jumps me to the import statement at the top of the file instead of opening the file with the real definition.

For example, I'm in an external library, (jumped here using Go To Definition), and from here, I again want to jump, so I put the cursor on the return statement on the Something token and hit "Go To Definition"...

from external.library.mod import Something
...
def scoped_session(arg):
    ...
    return Something(arg)

... which jumps me to the "from external.library.mod import Something" statement at the top of the file. I have the paths and sub-paths defined in External Libraries for the project.

I expect it to instead open the actual definition in the given package/file instead of jumping to the import statement.


Ubuntu 11.10, Eclipse 3.7.1, PyDev 2.4.0, Python 2.7.2

Cykooz
  • 11
  • 4
  • have you tried restarting the IDE? – WeaselFox Feb 09 '12 at 06:23
  • I encountered this problem about two years ago and while I do not know how to solve it. The developers of PyDev did not respond to a message about this issue in the tracker - http://sourceforge.net/tracker/?func=detail&aid=2935147&group_id=85796&atid=577329 – Cykooz Feb 09 '12 at 07:45
  • Answering on the PyDev bugtracker now (hope it'll e-mail me properly now). – Fabio Zadrozny Feb 09 '12 at 14:34
  • I answered your question on the PyDev bugtracker (probably notification through the e-mail you do not received). – Cykooz Feb 13 '12 at 06:14

2 Answers2

1

In Eclipse, for python project; we can jump to respective module (source file) and method (function definition). For this, we need to add the packages into PyDev – PYTHONPATH.

Project -> Properties -> PyDev – PYTHONPATH -> Add source folder Browse the particular package (source folder) from Project

Once done, just click on the search keyword, which you want to search and press F3. Else press Ctrl key and click on the search keyword.

Note: Better once restart the Eclipse.

Add Source Folder to PythonPath

akD
  • 1,137
  • 1
  • 10
  • 15
0

Go to Preferences -> PyDev -> Interpreter (Whichever)

When you first configure PyDev, it scans your system folders for modules (and in some cases I think it'll ask if you you want to scan 'everything' or not..), if the libraries you want were installed after you configured your interpreter, PyDev may just not know about them.

The quickest way to do it is to select all the libraries under site-packages, remove them, and then re-add the site-packages directory so it'll rescan everything.

Alternatively, just remove the config for your python binary and reinitialize your interpreter.

synthesizerpatel
  • 27,321
  • 5
  • 74
  • 91
  • No, it does not help. The bug in the External Library files. See example to reproduce the problem in my comment here - http://sourceforge.net/tracker/?func=detail&aid=2935147&group_id=85796&atid=577329 – Cykooz Apr 11 '12 at 13:22