简体   繁体   English

将ipython设置为pydev的解释器

[英]set ipython as interpreter for pydev

I would like to use IPython as interpreter in Pydev eclipse plugin. 我想在Pydev eclipse插件中使用IPython作为解释器。

I have IPython 0.10 and Pydev 2.5.0, running on linux (opensuse). 我有IPython 0.10和Pydev 2.5.0,在linux上运行(opensuse)。

When I go into Pydev preferences and try to set the IPython path (as explained on this page : http://pydev.org/manual_101_interpreter.html ) , I get the following error 当我进入Pydev首选项并尝试设置IPython路径时(如本页所述: http//pydev.org/manual_101_interpreter.html ),我收到以下错误

"Python stdlib not found or stdlib found without .py files" “找不到Python stdlib或没有.py文件找到stdlib”

The ipython interpreter works fine from a bash terminal, and i get the path from the command "which ipython". ipython解释器从bash终端正常工作,我从命令“ipython”获取路径。

Can someone help me ? 有人能帮我吗 ?

Thanks ! 谢谢 !

The interpreterInfo.py output is : interpreterInfo.py输出是:

python /home/softs/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py 


<xml>
<version>2.7</version>
<executable>/usr/bin/python</executable>
<lib path="out">/home/softs/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc</lib>
<lib path="ins">/usr/local/lib64/python2.7/site-packages/scikits.timeseries-0.91.3-py2.7-linux-x86_64.egg</lib>
<lib path="ins">/usr/local/lib64/python2.7/site-packages/distribute-0.6.19-py2.7.egg</lib>
<lib path="ins">/usr/local/lib64/python2.7/site-packages/MeshPy-2011.1-py2.7-linux-x86_64.egg</lib>
<lib path="out">/data/dvp/python</lib>
<lib path="out">/home/mayet</lib>
<lib path="ins">/usr/lib/python27.zip</lib>
<lib path="ins">/usr/lib64/python2.7</lib>
<lib path="ins">/usr/lib64/python2.7/plat-linux2</lib>
<lib path="ins">/usr/lib64/python2.7/lib-tk</lib>
<lib path="ins">/usr/lib64/python2.7/lib-old</lib>
<lib path="ins">/usr/lib64/python2.7/lib-dynload</lib>
<lib path="ins">/usr/lib64/python2.7/site-packages</lib>
<lib path="ins">/usr/lib64/python2.7/site-packages/PIL</lib>
<lib path="ins">/usr/local/lib64/python2.7/site-packages</lib>
<lib path="ins">/usr/local/lib/python2.7/site-packages</lib>
<lib path="ins">/usr/lib64/python2.7/site-packages/gtk-2.0</lib>
<lib path="ins">/usr/lib/python2.7/site-packages</lib>
<lib path="ins">/usr/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info</lib>
<lib path="ins">/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode</lib>
<forced_lib>__builtin__</forced_lib>
<forced_lib>__main__</forced_lib>
<forced_lib>_ast</forced_lib>
<forced_lib>_codecs</forced_lib>
<forced_lib>_sre</forced_lib>
<forced_lib>_symtable</forced_lib>
<forced_lib>_warnings</forced_lib>
<forced_lib>errno</forced_lib>
<forced_lib>exceptions</forced_lib>
<forced_lib>gc</forced_lib>
<forced_lib>imp</forced_lib>                                                                                                                                                        
<forced_lib>marshal</forced_lib>                                                                                                                                                    
<forced_lib>posix</forced_lib>                                                                                                                                                      
<forced_lib>pwd</forced_lib>                                                                                                                                                        
<forced_lib>signal</forced_lib>                                                                                                                                                     
<forced_lib>sys</forced_lib>                                                                                                                                                        
<forced_lib>thread</forced_lib>                                                                                                                                                     
<forced_lib>xxsubtype</forced_lib>                                                                                                                                                  
<forced_lib>zipimport</forced_lib>                                                                                                                                                  
</xml>Traceback (most recent call last):                                                                                                                                            
  File "/home/softs/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py", line 142, in <module>                                                              
raise RuntimeError('Ok, this is so that it shows the output (ugly hack for some platforms, so that it releases the output).')                                                   
RuntimeError: Ok, this is so that it shows the output (ugly hack for some platforms, so that it releases the output).  

This means that in none of those paths (the xml tag), PyDev can find the Python library files (such as threading.py or traceback.py, etc -- note that this may happen if you have only .pyc files too and not the actual .py files in one of those folders). 这意味着在这些路径(xml标签)中都没有,PyDev可以找到Python库文件(例如threading.py或traceback.py等) - 请注意,如果你只有.pyc文件,这可能会发生其中一个文件夹中的实际.py文件)。

Or you didn't leave the folder containing the Python libraries selected during the interpreter configuration process. 或者您没有离开包含在解释器配置过程中选择的Python库的文件夹。

Note that you don't really set 'IPython' as an interpreter, you set Python itself as the interpreter and you can have the IPython library installed to make use in the interactive console: http://pydev.org/manual_adv_interactive_console.html (but from your output it seems you're doing this right as you're pointing to configure /usr/bin/python). 请注意,您并未真正将“IPython”设置为解释器,而是将Python本身设置为解释器,并且可以安装IPython库以在交互式控制台中使用: http//pydev.org/manual_adv_interactive_console.html (但是从你的输出看来你正好这样做,因为你指的是configure / usr / bin / python)。

To get Ipython as default shell do the followings: go to Window-->Preferences-->PyDev-->Interactive Console. 要将Ipython作为默认shell,请执行以下操作:转到Window - > Preferences - > PyDev - > Interactive Console。 In the Initial Interpreter Commands filed add this 2 commands: import IPython; 在Initial Interpreter Commands字段中添加以下两个命令:import IPython; IPython.Shell.IPShell().mainloop() Now every time you'll start your console IPython will be launched as default. IPython.Shell.IPShell()。mainloop()现在,每次启动控制台时,IPython都将默认启动。

Note1: of course,you need IPython installed of your system for this to work Note2: the interpreter will still complain with something like "In [1]: PyDev console: using default backend (IPython not available)" but it is because it prints it automatically before you have the chance to import IPython. 注意1:当然,你需要安装你系统的IPy才能工作注意2:解释器仍会抱怨类似“In [1]:PyDev控制台:使用默认后端(IPython不可用)”,但这是因为它打印在您有机会导入IPython之前自动进行。

Hope this helps!! 希望这可以帮助!! Bye!! 再见!

Besides the steps mentioned by @mr_endres I also had to verify the path for site-packages. 除了@mr_endres提到的步骤之外,我还必须验证site-packages的路径。 Had the folder but turned out it was empty. 有文件夹,但结果是空的。

To verify the proper path you can start ipython from terminal and do the following (just an example): 要验证正确的路径,您可以从终端启动ipython并执行以下操作(仅作为示例):

 1. import numpy as np
 2. np.__file__

which returned: 返回:

'`/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages`/numpy/__init__.pyc'

I then added: '/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages' to the PYTHONPATH (in Eclipse its through preferences->PyDev->Interpreter - Python -> New folder in the PYTHON PATH section). 然后我将'/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages'添加到PYTHONPATH(在Eclipse中通过首选项 - > PyDev - >解释器 - Python - > PYTHON PATH部分中的新文件夹)。

For me the following two steps worked: 1) Add "/usr/lib/python2.7/site-packages/" to the PYTHONPATH 2) Enable under Window->Preferences->PyDev->Interactive Console the option "Connect console to Variables Debug View" 对我来说,以下两个步骤有效:1)将“/usr/lib/python2.7/site-packages/”添加到PYTHONPATH 2)在Window-> Preferences-> PyDev-> Interactive Console下启用选项“Connect console to变量调试视图“

Strangely only with the second step IPython started ... 奇怪的是,只有第二步IPython开始......

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

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