简体   繁体   English

如何在Eclipse中添加新的Pydev解释器

[英]How to add a new Pydev Interpreter in Eclipse

Ok so I have Pydev installed on 2 machines. 好的,所以我在2台计算机上安装了Pydev。 For some reason I have 3.5.1 on a laptop and 2.7 on the desktop. 由于某种原因,我在笔记本电脑上有3.5.1,在台式机上有2.7。 Now a project I have on the 2.7 machine (desktop) throws syntax errors on the other machine (laptop), which I guess must be because they are running different versions of Python, since I can't see any other possible cause. 现在,我在2.7台计算机(台式机)上有一个项目在另一台计算机(笔记本电脑)上引发了语法错误,我想这可能是因为它们运行的​​是不同版本的Python,因为我看不到任何其他可能的原因。 As such, I installed 2.7 on the laptop, but before attempting to change the default interpreter to 2.7 (which I may or may not have done correctly: I just added the 2.7 path and moved it to the top of the list of (2) interpreters) I tried fiddling with the launch preferences in an effort to make it work. 因此,我在笔记本电脑上安装了2.7,但是在尝试将默认解释器更改为2.7之前(我可能会或可能没有正确完成:我只是添加了2.7路径并将其移至(2)列表的顶部译员)我尝试摆弄启动首选项,以使其正常工作。 Now when I try running the project, I get this: 现在,当我尝试运行该项目时,我得到了:

https://imgur.com/0n63S0t https://imgur.com/0n63S0t

I tried googling things like 'how to add new interpreter in PyDev' but didn't find anything which helped. 我尝试使用类似“如何在PyDev中添加新的解释器”之类的工具进行搜索,但没有找到任何有帮助的方法。 Anyone know what on earth is going and how I might get the project which works fine on the desktop working on the laptop as well? 任何人都知道到底会发生什么,我如何才能获得在笔记本电脑上也可以在台式机上正常工作的项目?

I've noticed in this question: 我注意到这个问题:

Setting default Python grammar version in Eclipse PyDev 在Eclipse PyDev中设置默认的Python语法版本

that it basically asks what may be the same thing (although I'm not sure the result I get which I showed in the imgur link is actually to do with the Python version so this problem may not be the same as that in the other question I linked: it seems I may have 2 problems: 1 which is similar to that in the question I linked and a new 1 (shown in the imgur link, at the bottom, where it says 'Ran 0 tests in 0.000 s) possibly caused by fiddling with the launch preferences). 它基本上询问的可能是同一件事(尽管我不确定我在imgur链接中显示的结果实际上与Python版本有关,所以此问题可能与其他问题不同我链接了:看来我可能有2个问题:1个与我链接的问题类似,一个新的1个问题(显示在底部的imgur链接中,上面写着“ Ran 0 tests in 0.000 s)”摆弄启动偏好)。 My question is how to proceed on the laptop so that I can make the project work. 我的问题是如何在笔记本电脑上进行操作,以便使项目正常进行。 Could I do this by removing Python 3.5.1? 我可以通过删除Python 3.5.1来做到这一点吗? Is it not possible to have 2 different versions of Python on the same machine and to choose which you use for each given project? 同一台机器上不可能有2个不同版本的Python,并不能为每个给定项目选择使用哪个版本? If it is possible, how do you do this? 如果可能的话,您该怎么做? I actually tried removing 3.5.1 from the interpreters but the result is the same and when I checked the interpreters again, 3.5.1 was still there, so I would also like to know how to remove an interpreter. 我实际上尝试从解释器中删除3.5.1,但是结果是相同的,当我再次检查解释器时,3.5.1仍然存在,因此我也想知道如何删除解释器。 Everything about this seems so incredibly awkward. 关于此的一切似乎都令人难以置信。 Genuinely have no idea why things should be make so awkard. 真不知道为什么事情应该变得如此笨拙。

Edit: I think I've successfully changed the interpreter that's being used, thanks to Joe, but I still get the useless result when I run that I posted in the imgur link. 编辑:感谢Joe,我想我已经成功更改了正在使用的解释器,但是运行在imgur链接中发布的结果仍然无效。 It looks like it's running a 'Python unit-test' (whatever that is) and I want to restore it to what it used to do, which was just a standard run. 看起来它正在运行“ Python单元测试”(无论如何),我想将其恢复到以前的状态,这只是标准运行。 Any ideas appreciated. 任何想法表示赞赏。

Edit 2: turns out it just runs as whatever you last ran it as, by default and no option to change this, it seems. 编辑2:事实证明,它就像您上次运行时一样运行,默认情况下,似乎没有任何选项可以更改它。

Of course this is possible: 当然这是可能的:

Eclipse - Windows - Preferences - PyDev - Interpreters - Python Interpreter - New... Eclipse-Windows-首选项-PyDev-解释器-Python解释器-新...

Then you can seelct the interpreter per project: 然后,您可以为每个项目提供解释器:

Right-click project - Properties - PyDev-Interpreter/Grammar - Interpreter - Pick from list 右键单击项目-属性-PyDev解释器/语法-解释器-从列表中选择

As a note, it seems the files in your screenshot aren't .py files (ie: it's BarCodeTest when it should be BarCodeTest.py ), so, you don't have syntax highlighting nor anything associated to the PyDev editor. 作为一个说明,它似乎在你的屏幕截图文件不是.py文件(即:它是BarCodeTest当它应该是BarCodeTest.py ),所以,你没有语法高亮,也没有相关的PyDev的编辑东西。

After you change the file to a .py file, you should be able to just use F9 to run the current file. 将文件更改为.py文件后,您应该能够仅使用F9运行当前文件。 The getting started manual: http://www.pydev.org/manual_101_run.html has more information on ways to properly run a module. 入门手册: http : //www.pydev.org/manual_101_run.html包含有关正确运行模块的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM