Running external Python programs using Eclipse PyDev

I want to use the refactoring allowed by PyDev, but I think it's a little ridiculous to create a project folder in my Eclipse workspace for every little python script that I create.

I can get refactoring by editing the file in Eclipse using File > Open File... However, I still need to go to the terminal to run the file. It would be nice to run it in Eclipse.

I tried to configure Run > External Tools > External Tools Configurations... using Location

 /Library/Frameworks/Python.framework/Versions/Current/bin/python 

and arguments

 ${resource_loc} 

Presumably this will invoke the python interpreter using an open file. But this is not so. All I get is:

 Variable references empty selection: ${resource_loc} 

Stack Overflow.site/questions/460957 / ... has the same problem as me, but the selected answer has nothing to do with the empty problem ${resource_loc} .

How to run external python programs in Eclipse?

+7
source share
1 answer

The last PyDev has already improved the situation a bit ... the workflow for use with external files is as follows (check on PyDev 2.2.2 and Eclipse 3.7):

  • Drag the file from the file system to Eclipse (should open the file for editing).

  • Press F9 with an open editor to run the file ... It will still ask you to let the project use PYTHONPATH and the interpreter (you can probably just use any project that you have an interpreter that you want to use to run, or create the PyDev project as "external_projects" and associate them with it).

Please note that you need to correctly configure PyDev (the steps are available at: http://pydev.org/manual_101_root.html ), and if you completed the step to mark, repeat the last default run - http://pydev.org/ manual_101_run.html - pressing Ctrl + F11 will resume restarting (and you will no longer need to have this editor as active).

In the future, you can change the launch configuration in the menu: Run> Run Configuration.

+9
source

All Articles