eclipse运行python程序_使用Eclipse PyDev运行外部Python程序

I want to use the refactoring enabled by PyDev but think it is a little ridiculous to create a project folder in my Eclipse workspace for every single little python script I create.

I'm able to get refactoring by editing the file in Eclipse using File > Open File.... However, I still have to go to the Terminal to run the file. It would be nice to just run it in Eclipse.

I've tried setting up a Run > External Tools > External Tools Configurations... using the Location

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

and the Arguments

${resource_loc}

Presumably, this would call the python interpreter using the opened file. But it doesn't. All I get is:

Variable references empty selection: ${resource_loc}

This StackOverflow question has the same problem as I do, but the selected answer has nothing to do with the empty ${resource_loc} problem.

How do I run external python programs in Eclipse?

解决方案

The latest PyDev already has improved things a bit... the workflow for the use-case of dealing with external files is the following (checking on PyDev 2.2.2 and Eclipse 3.7):

Drag file from filesystem to Eclipse (should open the file to edit it).

Press F9 with the editor open to run the file... It'll still ask you for a project to resolve the PYTHONPATH and interpreter to be used (you can probably just use any project you have that has the interpreter you want to use for the run or create a PyDev project as 'external_projects' and bind those runs to it).

Note that you need to have PyDev already properly configured (steps available at: http://pydev.org/manual_101_root.html ) and if you followed the step to mark the rerun the last launch as the default -- http://pydev.org/manual_101_run.html -- pressing Ctrl+F11 will rerun that last launch again (and you no longer need to have that editor as the active one).

You may later on change that run configuration in the menu: Run > Run configurations.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值