加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

在vim中安装YouCompleteMe时遇到python问题

发布时间:2020-12-15 22:04:08 所属栏目:安全 来源:网络整理
导读:我已经按照 these instructions,在Vim中安装YouCompleteMe,但是当我发出时: ./install.py --clang-completer 出现以下错误消息: Searching Python 2.7 libraries...ERROR: found static Python library (/usr/local/lib/python2.7/config/libpython2.7.a)
我已经按照 these instructions,在Vim中安装YouCompleteMe,但是当我发出时:

./install.py --clang-completer

出现以下错误消息:

Searching Python 2.7 libraries...
ERROR: found static Python library (/usr/local/lib/python2.7/config/libpython2.7.a) but a dynamic one is required. You must use a Python compiled with the --enable-shared flag. If using pyenv,you need to run the command:
  export PYTHON_CONFIGURE_OPTS="--enable-shared"
before installing a Python version.
Traceback (most recent call last):
  File "./install.py",line 44,in <module>
    Main()
  File "./install.py",line 33,in Main
    subprocess.check_call( [ python_binary,build_file ] + sys.argv[1:] )
  File "/usr/local/lib/python2.7/subprocess.py",line 540,in check_call
    raise CalledProcessError(retcode,cmd)
subprocess.CalledProcessError: Command '['/usr/local/bin/python',u'/home/anmol/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py','--clang-completer']' returned non-zero exit status 1

现在我被困住了,我该怎么办?

解决方法

我检查了YouCompleteMe的构建系统,它使用了一个自定义构建脚本,该脚本使用Python模块distutils来查找Python库和包含目录的路径.您的/usr/local/Python安装可能在官方/ usr安装之前包含在您的PATH变量中,因此运行python可能会运行您的自定义安装,使得distutils返回其目录.

要检查是否为真,请尝试运行哪个python.我假设它会返回类似/usr/local/bin / python的东西.

在这一点上,我看到了几个选项.

>尝试运行YCM的安装脚本,指定哪个Python可执行文件应该显式运行:/usr/bin/python ./install.py –clang-completer
>在YouCompleteMe的插件目录中编辑脚本third_party / ycmd / build.py,以硬编码自定义Python安装的路径.例如,您可以使用以下内容替换现有的FindPythonLibraries函数:

def FindPythonLibraries():
    return ('/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so','/usr/include/python2.7')

请注意,这将使更新YouCompleteMe变得更加困难,因为您必须确保在更新其源时不会覆盖它.
>使用作为共享库构建的Python更新Python的自定义安装.详细信息将取决于您首先安装此Python版本的方式.您可以使用dpkg -S /usr/local/lib/python2.7/config/libpython2.7.a来检查是否通过包安装了它.此命令将告诉您安装该文件的软件包,除非您手动安装它(绕过软件包管理器).
>删除自定义/usr/local Python安装,同时确保安装了官方存储库中的Python(包python2.7和libpython2.7).

从长远来看,使用官方Python软件包可能会更好.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读