Pydev: Go to arbitrary module source? - eclipse

In Pydev, is there a convenient way to open arbitrary (external, globally installed) module? Say, I want to see the source of markdown.blockprocessors module. How can I do that without typing an import directive (import markdown.blockparser), using "Go To Definition" (F3) and removing the directive? It would be nice to see the hierarchy of the whole markdown package in the Package Explorer, but I don't know how.

There are 2 main ways of finding something without using F3:
Open Resource action (Ctrl+Shift+R): allows you to find any file in your workspace (so, it's useful not only for python modules, but any file, but those need to be in your workspace).
The PyDev tokens browser (Ctrl+Shift+T): allows you to find any token (class/method/attributes/globals -- but currently not module name) for modules in the PYTHONPATH (either source folder or external libraries under the project properties > pydev pythonpath). You can filter things as 'myproject.*something' (the dialog that opens provides instructions on how to filter tokens).

Add Markdown source code folder here::
Project properties -> PyDev PYTHONPATH -> Source folders.

Related

Gtkmm in Eclipse makefile project: "could not be resolved"

I am trying to migrate a custom C++ project which uses Gtkmm3.0 to Eclipse (Oxygen) on Ubuntu 16.04. The project has its own Makefile and builds fine from the terminal within Eclipse. What I have not been able to do so far is tell the indexer about Gtkmm, and I get lots of these (which is very annoying):
When I hover over the little red bugs, it says:
Type 'Cairo::RefPtr<Cairo::Context>' could not be resolved.
I have done a lot of Googling on this and found nothing so far because all answers seem to assume the project's build tools are managed by Eclipse (See this or this, for example). In my case I have a makefile project instead of an executable project and hence some options are not available to me. For example, the first links speaks about configuring the builder:
We have to add all this directories. On Eclipse select the Project->Properties menu option. Select C/C++ Build->Settings property page and GNU C++ Compiler->Directories from the Tool Settings tab. Now we have to add all directories. In my case (Makefile project) only two tabs are available there: Binary Parsers and Error Parsers.
How can I tell the Eclipse indexer I am using Gtkmm3.0?
Found the solution that works for me:
Open a terminal and enter:
pkg-config --cflags gtkmm-3.0
You will see a list of includes directories (starting with -I). These are the directories you want to add in Eclipse so that it can locate the Gtkmm symbols in the editor.
In Eclipse, go to:
Project -> Properties -> C++ General -> Paths and Symbols
In the Includes tab, select GNU C++. You need to add here add the include directories found in step 1. There is no automated way to do this, yo must enter them one by one.
One trick that can save you some time is to edit manually the Eclipse project setting XML file and add the include directories directly in the XML file. By the end, you should have something that looks like this:
That did it for me, hope this helps!

netbeans how is it organized

i have a running package consisting of classes all written by myself, except of course for some basic java libraries. The reason is simple : everytime i try to import an external jar to use it instead of writing it myself, netbeans fails to find the files, so it simply does not work.
as you will understand, i'm really not happy with this situation, so i looked for a solution and tried everything to get external files being integrated in my package ...
So my question : does anyone know a site with a simple and clear explanation on how netbeans deals with the different files, and where they should be stored ? I've read all questions and answers about importing external jar files, but nothing helps ...
To use an external library:
Open the project properties
Click on libraries
Click on "Add JAR/Folder"
Select the jar file(s) in question
If a library consists of multiple jar files and you want to use that in multiple projects:
Open "Tools -> Libraries"
Click "New Library"
Add the jar files using the "Add JAR/Folder" button
Close the "Ant Library Manager" window
Open the project properties
Click on "libraries"
Add the global library by clicking on the "Add Library button"
The NetBeans manual has a lot of information on how to use the IDE:
http://docs.oracle.com/cd/E50453_01/doc.80/e50452/toc.htm
The chapter "Managing the classpath" describes how to manage external libraries:
http://docs.oracle.com/cd/E50453_01/doc.80/e50452/create_japps.htm#CHDFBFAD
The chapter "Creating Dependencies Between Projects" describes how you can re-use code from one project in another:
http://docs.oracle.com/cd/E50453_01/doc.80/e50452/create_japps.htm#CHDIBBEB

"Go to definition" from PyDev not work in External Library files

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

Pydev say, "Unresolved import" error

hm..
Sometime, PyDev say "Unresolved import error".
In my environment
Python2.6.6 Eclipse3.7 PyDev2.2.2
Errors are.
> Unresolved import: pycassa -> import pycassa Unresolved import:
> WebSocketHandler -> from geventwebsocket.handler import
> WebSocketHandler Unresolved import: tweepy -> import tweepy
Is there any helpfull information?
Had the same problem. In the end I was able to fix the problem by deleting my old interpreter in Preferences > PyDev > Interpreters, and creating a new interpreter called "python" which had the correct paths. After quitting and reopening eclipse, pydev found all my modules.
Probably your PYTHONPATH is not set properly (or if those are libraries in the interpreter, maybe you added them after configuring it).
See: http://pydev.org/manual_101_interpreter.html for references (note the part on forced builtins there as it might be your case).
You get an unresolved import if the required module cannot be found. Modules are searched for in the current working directory and the directories listed in sys.path. Your python cannot find the modules pycassa and tweepy it appears.
Might want to check this: http://klaith.wordpress.com/2009/06/12/pydev-unresolved-import-errors/
I solved by recreate the interpreter. There is a guide at pedev.org:
What if I add something new in my System PYTHONPATH after configuring
it?
If you add something to your python installation, you need to either
add it manually as a 'new folder' in the System PYTHONPATH (if it's
still not under a folder in the PYTHONPATH) or (recommended) remove
your interpreter and add it again, then, press apply.
Note that if you added a library that's already under a folder in the
PYTHONPATH, you have to at least go to the interpreter preferences and
press apply so that it clears its internal caches (after the
configuration is done, things are set in stone for PyDev)
Thanks for Fabio Zadrozny and nicodjimenez.
I had a similar problem before. I solved the problem by this steps:
1)Window > Preferences > PyDev > Interpreters > Python Interpreter
2)Delete the Python Interpreter path you added previously
3)Add "New" Python Interpreter and choose python.exe path
4)Check Libraries tab (I found the problem at this step.)
Check your path name, is it true or false? Eclipse detect "C:\Python27\lib" but it should be "C:\Python27\libs" and "C:\Python27\Lib".
In the properties for your pydev project, there's a pane called "PyDev - PYTHONPATH", with a sub-pane called "External Libraries". You can add source folders (any folder that has an init.py) to the path using that pane. Your project code will then be able to import modules from those source folders.
Check this two links it may be helps to you,
Unresolved Import Issues with PyDev and Eclipse
Unresolved import: models
Is pycassa found as a symlink within a directory on your PYTHONPATH? Pydev apparently has a bug where its code analysis cannot follow symlinks (and hence will not see your libraries). The python interpreter can though of course.
I was having a similar problem with the dbfpy module.
I had downloaded the tar archive and installed the source files in /usr/lib/python2.7/dist-packages
With this I was able to import the packages in IDLE and even run the code in Eclipse. However the pydev import was still showing as an error with the message "unresolved import"
As suggested by Fabio, I checked the PyDev documentation for forced-builtins. Just adding the name of the package ("dbfpy" in my case to the Forced Builtit tab of Python Interpretr in Eclipse) solved the issue.
(I know the answer is a bit late)
if you installed a python package using, for example: pip install django
i solved the unresolved import issue doing this:
In eclipse:
Window > Preferences
In the left panel tree structure go to:
PyDev > Interpreter - Python
In the upper right panel be sure to have the correct interpreted selected
and in the bottom right panel, click New Folder, navigate to your python installation site-packages (usually in c:\Python33\Lib\site-packages) and search for a folder that ends with .egg-info
In my pc it is "C:\Apps\Environments\Python33\Lib\site-packages\Django-1.5.4-py3.3.egg-info" since i installed python in C:\Apps\Environments, should be different in your case.
This worked with django and selenium, should work with all others as well (as far as i know)
Adding the corresponding package folder ending with '.egg-info' to PyDev > Interpreter - Python - library will resolve the problem.
In Linux, it is usually under /usr/local/lib/pythonX.X/dist-packages
Add site-packages path in environmental variables.
Right click on
computer -> properties -> advanced system settings -> Environmental
variables
.
After that is done, remove the python interpreter and add it again in eclipse.
right click project name in
eclipse --> properties --> python interpreter
.
Hope it works.

How can I add a project specific #INC module-path to Komodo without breaking syntax checking?

For a Perl porting project I am using ActiveState's Komodo IDE 5.1
For external reasons, the xyz.pm modules reside in a different directory tree.
By adding a PERL5LIB=<> under the "environemt" tab of the debu/run dialog, I can show Komodo/Perl how to run the script.
Unfortunately the syntax checking doesn't seem to evaluate those directives and the IDE claims there was a fatal "can't locate xyz.pm" error, despite the fact that the script runs fine.
One way to fix this is to add the module path using the "Additional Perl Import Directories" under <Edit><Preferences><Languages><Perl>, but that is a global directive, not project specific, which leads to all kinds of interesting problems when module names collide.
So, how can I configure the Komodo IDE to store "Additional Perl Import Directories" [the #INC path for syntax checking] with the project?
EDIT: The suggested method of adding use lib qw'../lib'; might be helpful, if only I could make it execute in the IDE only. But this code must not show up in the production environment, where the start-up script sets the environment correctly.
For Komodo IDE 5.0.1:
Project (top menu bar) -> -> Properties -> Languages (left menu) -> Perl
This will allow you to add "Additional Perl Import Directories" which is what you want.
I have put a use lib qw'../lib'; to get Komodo to highlight correctly.
It just adds ../lib to #INC.