Gere
Gere

Reputation: 12697

How to pass PYTHONPATH to external tools in Pydev/Eclipse?

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.

Upvotes: 1

Views: 597

Answers (3)

Fabio Zadrozny
Fabio Zadrozny

Reputation: 25332

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

Upvotes: 2

greg-449
greg-449

Reputation: 111142

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

Upvotes: 0

lorenzog
lorenzog

Reputation: 3609

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

Upvotes: 0

Related Questions