1

I'd like to set up some "External tool" for Eclipse. This tool is meant to be run for a particular project and also requires PYTHONPATH to be initialized.

Is there a way to pass the PYTHONPATH to the tool execution, just as the Python interpreter configured in Pydev would usually do?

EDIT: My intend is to set the PYTHONPATH depending on the current active Pydev project - this is only known to the project. So it's not a hardcoded solution, I'm looking for.

Gere
  • 12,075
  • 18
  • 62
  • 94

3 Answers3

2

PyDev does that on its integrations (i.e.: PyLint), but currently does not provide a variable which you can use to resolve on external tools, so, please create a feature request for that.

An option in the current structure without the variable would be using the scripting layer to execute an external tool (http://pydev.org/manual_articles_scripting.html). From the scripting layer it should be possible to get the PYTHONPATH from the editor.

i.e.: something like:

nature = editor.getPythonNature()
if nature:   
    nature.getPythonPathNature().getCompleteProjectPythonPath(nature.getProjectInterpreter(),
                            nature.getRelatedInterpreterManager())
Fabio Zadrozny
  • 24,814
  • 4
  • 66
  • 78
  • Thanks. Great work btw! Just to make sure I havent missed something: Is there another way to run an IPython HTML Notebook with the PYTHONPATH of the current project? – Gere Jan 04 '14 at 09:36
  • Well, I don't think you actually need an external tool to run python code from PyDev... can't you just do a regular Python run in this case? (not sure exactly what you want to accomplish, so, this may or may not be an option there -- I was under the impression that you wanted to do a builder). – Fabio Zadrozny Jan 04 '14 at 16:38
  • I don't actually want to run particular Python code, but just open an IPython HTML Notebook with all module paths loaded :) – Gere Jan 04 '14 at 21:37
0

Assuming your case is not covered by this or this questions, Eclipse should honor environment variables. Set your PYTHONPATH accordingly (see this answer or this answer on how to do it on windows 7).

Community
  • 1
  • 1
lorenzog
  • 3,483
  • 4
  • 29
  • 50
  • I actually mean that I want to set it dynamically, which depends on the currently active project. It's not something I can hardcode. – Gere Dec 30 '13 at 20:52
  • Short of using virtualenv and launching Eclipse from the command line after you entered the virtual environment I would not know how to do it *easily*. – lorenzog Dec 31 '13 at 08:51
0

The Run > External Tools > External Tools Configurations dialog lets you configure external tools. You can specify environment variables on the Environment tab.

greg-449
  • 109,219
  • 232
  • 102
  • 145
  • I actually mean that I want to set it dynamically, which depends on the currently active project. It's not something I can hardcode. – Gere Dec 30 '13 at 20:53