使用 Eclipse PyDev 运行外部 Python 程序
我想使用 PyDev 启用的重构,但认为在 Eclipse 工作区中为我创建的每个小 python 脚本创建一个项目文件夹有点荒谬。
我可以通过使用 File > 在 Eclipse 中编辑文件来进行重构。打开文件...
。但是,我仍然需要转到终端来运行该文件。如果能在 Eclipse 中运行它就好了。
我尝试设置 Run >外部工具>使用位置
/Library/Frameworks/Python.framework/Versions/Current/bin/python
和参数
${resource_loc}
的外部工具配置...据推测,这将使用打开的文件调用python解释器。但事实并非如此。我得到的只是:
Variable references empty selection: ${resource_loc}
这个 StackOverflow 问题 和我有同样的问题,但所选答案与空的 ${resource_loc}
问题无关。
如何在 Eclipse 中运行外部 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最新的 PyDev 已经做了一些改进...处理外部文件的用例的工作流程如下(检查 PyDev 2.2.2 和 Eclipse 3.7):
将文件从文件系统拖到 Eclipse(应该打开文件进行编辑)。
在编辑器打开的情况下按 F9 来运行文件...它仍然会要求您提供一个项目来解析 PYTHONPATH 和要使用的解释器(您可能可以使用任何具有您想要的解释器的项目用于运行或创建一个 PyDev 项目作为“external_projects”并将这些运行绑定到它)。
请注意,您需要正确配置 PyDev(步骤如下:http://pydev.org/manual_101_root.html< /a> ),如果您按照步骤将上次启动标记为默认重新运行 - http://pydev.org/manual_101_run.html - 按 Ctrl+F11 将重新运行上次启动(并且您不再需要将该编辑器作为活动编辑器)。
您稍后可以在菜单中更改运行配置:“运行”>“运行”。运行配置。
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.