安装YouCompleteMe后,Vim错误`未定义符号:PyUnicodeUCS2_AsWideChar`

时间:2015-11-01 23:20:56

标签: python vim youcompleteme

我尝试在Vbu 7.4上安装YouCompleteMe,并在Ubuntu 15.10上添加了补丁1-712。

我已经通过hand编译了YouCompleteMe,因为我遇到了这样的错误:

/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

FAQ Section所述,添加-DPYTHON_LIBRARY=/usr/lib/libpython2.7.so即可解决问题。因此,请与此相提并论:

cmake -G "Unix Makefiles" -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

然后:

cmake --build . --target ycm_support_libs --config Release

我在编译这段时间时没有遇到任何错误,但是当我打开Vim I时,我看到了这一点:

   import ycm_client_support
                            ImportError: /home/austin/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_support.so: undefined symbol: PyUnicodeUCS2_AsWideChar















Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPython:
line   33:
Traceback (most recent call last):
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPython:
line   33:
  File "<string>", line 29, in <module>
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPython:
line   33:
  File "/home/austin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/youcompleteme.py", line 32, in <module>
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPython:
line   33:
    from ycm.omni_completer import OmniCompleter
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPython:
line   33:
  File "/home/austin/.vim/bundle/YouCompleteMe/autoload/../python/ycm/omni_completer.py", line 22, in <module>
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPython:
line   33:
    from ycmd.completers.completer import Completer
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPyth
on:
line   33:
  File "/home/austin/.vim/bundle/YouCompleteMe/autoload/../third_party/ycmd/ycmd
/completers/completer.py", line 25, in <module>
Press ENTER or type command to continue
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPyth
on:
line   33:
    from ycm_client_support import FilterAndSortCandidates
Error detected while processing function youcompleteme#Enable..<SNR>64_SetUpPyth
on:
line   33:
ImportError: /home/austin/.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_
support.so: undefined symbol: PyUnicodeUCS2_AsWideChar

有谁知道如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

这看起来像Python FAQ =&gt;中描述的问题。 https://docs.python.org/2/faq/extending.html#when-importing-module-x-why-do-i-get-undefined-symbol-pyunicodeucs2

&#34;解决此问题的唯一方法是使用使用相同大小的Unicode字符构建的Python二进制文件编译的扩展模块。&#34;

您可以使用以下方法测试python的unicode字符大小:

import sys
if sys.maxunicode > 65535:
  print 'UCS4 build'
else:
  print 'UCS2 build'