[英]how to run python in eclipse with both py2 and py3?
pre: 前:
question: 题:
I choose one py file, I want run it in py2, then i want it run in py3(manually). 我选择一个py文件,我想在py2中运行它,然后我希望它在py3中运行(手动)。
I know that each file cound has it's run configuration, but it could only choose one interpreter a time. 我知道每个文件库都有它的运行配置,但是一次只能选择一个解释器。
I also know that py.exe could help you get the right version of python. 我也知道py.exe可以帮助您获取正确版本的python。
I tried to add an interpreter with py.exe, but pydev keeps telling me that "python stdlibs" is necessary for a interpreter while only python3's lib shows up. 我试图用py.exe添加解释器,但是pydev一直告诉我,解释器需要“ python stdlibs”,而只有python3的lib出现。
so, is there a way just like right click the file and choose "run use interpreter xxx"? 因此,有没有一种方法类似于右键单击文件并选择“运行使用解释器xxx”? or, does pydev has the ability to choose interpreters by "#! python2"/"#! python3" at file head?
或者,pydev是否可以在文件头通过“#!python2” /“#!python3”选择解释器?
I didn't understand what's the actual workflow you want... 我不明白您想要的实际工作流程是什么...
Do you want to run each file on a different interpreter (say you have mod1.py
and want to run it always on py2
and then mod2.py
should be run always on py3
) or do you want to run the same file on multiple interpreters (ie: you have mod1.py
and want to run it both on py2
and py3
) or something else? 您是否要在不同的解释器上运行每个文件(例如,您拥有
mod1.py
并希望始终在py2
上运行它,然后mod2.py
应该始终在py3
上py3
)还是要在多个解释器上运行同一文件? (即:您有mod1.py
并想同时在py2
和py3
上运行它)或其他东西?
So, please give more information on what's your actual problem and what you want to achieve... 因此,请提供有关您的实际问题和您想要实现的目标的更多信息。
Options to run a single file in multiple interpreters: 在多个解释器中运行单个文件的选项:
Always run with the default interpreter (so, make a regular run -- F9
to run the current editor -- change the default interpreter -- using Ctrl+shift+Alt+I
-- and then rerun with Ctrl+F11
). 始终使用默认解释器运行(因此,请定期运行
F9
以运行当前编辑器-更改默认解释器-使用Ctrl+shift+Alt+I
然后使用Ctrl+F11
重新运行)。
Create a .sh
/ .bat
which will always do 2 launches (initially configure it to just be a wrapper to launch with one python, then, after properly configuring it inside of PyDev that way change it to launch python 2 times, one with py2 and another with py3 -- note that I haven't tested, but it should work in theory). 创建一个始终执行2次启动的
.sh
/ .bat
(最初将其配置为仅作为包装器以使用一个python启动,然后在PyDev内部正确配置该方式后将其更改为以python 2次启动,一次使用py2另一个使用py3-请注意,我尚未测试过,但理论上应该可以使用)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.