eclipse 在Eclipse中为不同项目使用不同版本的python
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/543466/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using different versions of python for different projects in Eclipse
提问by Baltimark
So, I'm slowly working in some Python 3.0, but I still have a lot of things that rely on 2.5.
所以,我慢慢地在一些 Python 3.0 上工作,但我仍然有很多依赖 2.5 的东西。
But, in Eclipse, every time I change projects between a 3.0 and a 2.5, I need to go through
但是,在 Eclipse 中,每次我在 3.0 和 2.5 之间更改项目时,我都需要通过
Project -> Properties -> project type.
项目 -> 属性 -> 项目类型。
Issue 1:if I just switch the interpreter in the drop down box, that doesn't seem to change anything. I need to click "click here to configure an interpreter not listed", and UPthe interpreter I wish to use.
问题 1:如果我只是在下拉框中切换解释器,那似乎没有任何改变。我需要点击“点击这里来配置未列出的解释”,和UP解释我希望用。
Issue 2:That would be fine if I was switching to 3.0 for every project for the rest of my life, but I still am doing a lot of switching between projects and I don't see that changing anytime soon. So, I'm just trying to save a few operations.
问题 2:如果我在余生中的每个项目都切换到 3.0,那会很好,但我仍然在项目之间进行大量切换,而且我认为这种情况不会很快发生变化。所以,我只是想节省一些操作。
Is there a way to configure Eclipse so that it remembers which interpreter I want associated with which project?
有没有办法配置 Eclipse 以便它记住我想要与哪个项目关联的解释器?
What if I created an entirely new workspace? Is "interpreter" a property of a workspace?
如果我创建了一个全新的工作区会怎样?“解释器”是工作区的属性吗?
Also, it doesn't seem to matter what I choose when I create a new project via File -> New -> Pydev Project. Whatever I last selected through "Properties" is what eclipse is using.
此外,当我通过 File -> New -> Pydev Project 创建新项目时,我选择什么似乎并不重要。我最后通过“属性”选择的内容是 eclipse 正在使用的内容。
This is Eclipse 3.4.0, running in Windows XP.
这是 Eclipse 3.4.0,在 Windows XP 中运行。
采纳答案by Kiv
You can set the interpreter version on a per-script basis through the Run Configurations menu.
您可以通过“运行配置”菜单在每个脚本的基础上设置解释器版本。
To do this go to Run -> Run Configurations, and then make a new entry under Python Run. Fill in your project name and the main script, and then go to the Interpeter tab and you can pick which interpreter you want to use for that script.
为此,请转到 Run -> Run Configurations,然后在 Python Run 下创建一个新条目。填写您的项目名称和主脚本,然后转到 Interpeter 选项卡,您可以选择要用于该脚本的解释器。
I've used this to have Python 2.2, 2.5, and 3.0 projects in the same workspace.
我已经使用它在同一工作区中拥有 Python 2.2、2.5 和 3.0 项目。
回答by Baltimark
OK --
好的 -
It definitely seems like "interpreter" is a property of your "workspace". I hadn't really considered that too much because I always thought of the workspace as "a folder in which I keep whatever" instead of a consistent unified environment for one kind of development.
看起来“解释器”绝对是您“工作区”的属性。我并没有真正考虑太多,因为我一直认为工作区是“一个文件夹,我可以在其中保存任何东西”,而不是为一种开发提供一致的统一环境。
Also, you can't switch between workspaces in one instance of Eclipse (it shuts down and restarts), but you can run two instances of Eclipse at once, one for each workspace.
此外,您无法在一个 Eclipse 实例中的工作区之间切换(它会关闭并重新启动),但您可以同时运行两个 Eclipse 实例,每个工作区运行一个。
Now, I guess I like the fact that Eclipse handles it that way. It has a more "modular" feel, and what originally bothered me I now think it sensible. I don't need to worry about having two interpreters to choose from, or choosing the default or moving one up. I just need to worry about which workspace I'm in.
现在,我想我喜欢 Eclipse 以这种方式处理它的事实。它有一种更“模块化”的感觉,最初困扰我的事情我现在认为是明智的。我不需要担心有两个解释器可供选择,或者选择默认值或移动一个。我只需要担心我在哪个工作区。
Hope this helps someone. . .
希望这可以帮助某人。. .
EDIT: as noted by Kiv, "interpreter" is not a property of your "workspace" (as I stated above). Instead, for any project, there is a "run configuration" (incidentally, there is also a debug configuration). The run config allows the user to set the executable, and the path, and a number of other options.
编辑:正如Kiv所指出的,“解释器”不是您的“工作区”的属性(如上所述)。相反,对于任何项目,都有一个“运行配置”(顺便说一句,还有一个调试配置)。运行配置允许用户设置可执行文件、路径和许多其他选项。
*I'm sure these things are known to long-time users, but I never had to deal with this until I changed python versions.**
*我确信这些东西是长期用户所知道的,但在我更改 python 版本之前我从来没有处理过这个问题。**