Vim:处理函数jedi#init_python时检测到错误:

时间:2018-08-03 08:44:22

标签: python vim virtualenv

我是vim的新用户。我正在尝试使Vim编辑器成为python IDE。通常,我将virtualenv用于python工作。

所以问题是vim-editor在一个环境中似乎可以正常工作,而在不同的环境中却引发错误。两种环境(假设env1和env2)具有相同的依赖关系。但是两者都会显示出不同的系统路径结果。

Env1

In [1]: import sys; sys.path
Out[1]: 
['',
 '/Users/amit/.virtualenvs/env1/bin',
 '/Users/amit/.virtualenvs/env1/lib/python27.zip',
 '/Users/amit/.virtualenvs/env1/lib/python2.7',
 '/Users/amit/.virtualenvs/env1/lib/python2.7/plat-darwin',
 '/Users/amit/.virtualenvs/env1/lib/python2.7/plat-mac',
 '/Users/amit/.virtualenvs/env1/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/amit/.virtualenvs/env1/lib/python2.7/lib-tk',
 '/Users/amit/.virtualenvs/env1/lib/python2.7/lib-old',
 '/Users/amit/.virtualenvs/env1/lib/python2.7/lib-dynload',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/amit/.virtualenvs/env1/lib/python2.7/site-packages',
 '/Users/amit/.virtualenvs/env1/lib/python2.7/site-packages/django_s3direct-1.0.4-py2.7.egg',
 '/Users/amit/.virtualenvs/env1/lib/python2.7/site-packages/IPython/extensions',
 '/Users/amit/.ipython']

Env2

In [1]: import sys; sys.path
Out[1]: 
['',
 '/Users/amit/.virtualenvs/env2/bin',
 '/Users/amit/.virtualenvs/env2/lib/python27.zip',                                                        
 '/Users/amit/.virtualenvs/env2/lib/python2.7',
 '/Users/amit/.virtualenvs/env2/lib/python2.7/plat-darwin',                                               
 '/Users/amit/.virtualenvs/env2/lib/python2.7/plat-mac',                                                  
 '/Users/amit/.virtualenvs/env2/lib/python2.7/plat-mac/lib-scriptpackages',                               
 '/Users/amit/.virtualenvs/env2/lib/python2.7/lib-tk',                                                    
 '/Users/amit/.virtualenvs/env2/lib/python2.7/lib-old',                                                   
 '/Users/amit/.virtualenvs/env2/lib/python2.7/lib-dynload',                                               
 '/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7',                  
 '/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',      
 '/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',           
 '/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',         
 '/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Users/amit/.virtualenvs/env2/lib/python2.7/site-packages',                                             
 '/Users/amit/.virtualenvs/env2/lib/python2.7/site-packages/IPython/extensions',                          
 '/Users/amit/.ipython']

您可能会注意到 Env1 的路径与 / System / Library / Frameworks / 相关,而 Env2 的路径与 / usr相关/local/Cellar/python@2/2.7.14_3/Frameworks / 。我不明白为什么会这样。

当我在 env1 中打开文件时,它会正常打开,但是当我在 env2 中打开文件时,它将引发给定的错误。

Error detected while processing function jedi#init_python:                                                       
line   24:                                                                                                       
Error: jedi-vim failed to initialize Python: jedi#setup_python_imports: ImportError: cannot import name _remove_d
ead_weakref (in function jedi#init_python[4]..<SNR>54_init_python[27]..jedi#setup_python_imports, line 27). See :
messages for more information.                                                                                   
Error detected while processing function LoadRope:                                                               
line    4:                                                                                                       
Traceback (most recent call last):                                                                               
  File "<string>", line 1, in <module>                                                                           
  File "/Users/amit/.virtualenvs/env2/lib/python2.7/site-packages/ropevim.py", line 7, in <module>         
    import tempfile                                                                                              
  File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", 
line 32, in <module>                                                                                             
    import io as _io                                                                                             
  File "/usr/local/Cellar/python@2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 5
1, in <module>                                                                                                   
    import _io                                                                                                   
ImportError: dlopen(/Users/amit/.virtualenvs/env2/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: _
_PyCodecInfo_GetIncrementalDecoder                                                                               
  Referenced from: /Users/amit/.virtualenvs/env2/lib/python2.7/lib-dynload/_io.so                          
  Expected in: flat namespace                                                                                    
 in /Users/amit/.virtualenvs/env2/lib/python2.7/lib-dynload/_io.so  

env2 中的python依赖关系在下面给出

$ pip freeze
ipython==5.8.0
jedi==0.12.1
rope==0.10.7
ropemode==0.4
ropevim==0.7.0

我不明白,env2出了什么问题?任何帮助,将不胜感激。谢谢。

0 个答案:

没有答案