您当前的位置: 首页 >  Python

ITKEY_

暂无认证

  • 0浏览

    0关注

    732博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

nvim 0.5.1不支持python3.10排错笔记

ITKEY_ 发布时间:2021-10-10 12:31:50 ,浏览量:0

现象

最近把python升级到最新版本3.10,发现nvim中不识别了。

原因分析

网上查了一下,好像根据原因是:

if a:version == 3 && str2float(pyversion) < 3.3
      call health#report_warn('Python 3.3+ is recommended.')
endif

这个bug挺逗的。

3.10 < 3.3 3.9 > 3.3 而实际上版本3.10>3.9而不能把它直接当数字比大小。

程序认为python 3.10版本小于3.3,导致bug的产生。

Nvim 0.5.1 checkhealth日志
- INFO: Executable: Not found                                                                                       ## Python 3 provider (optional)                              - WARNING: No Python executable found that can `import     neovim`. Using the first available executable for          diagnostics.                                               - ERROR: Python provider error:                              - ADVICE:                                                    - provider/pythonx: Could not load Python 3:                   /data/data/com.termux/files/usr/bin/python3 is             Python 3.10 and cannot provide Python >= 3.3.              /data/data/com.termux/files/usr/bin/python3.10
          is Python 3.10 and cannot provide Python >= 3.3.
          python3.9 not found in search path or not                  executable.
          python3.8 not found in search path or not
          executable.
          python3.7 not found in search path or not
          executable.
          python3.6 not found in search path or not                  executable.                                                /data/data/com.termux/files/usr/bin/python is
          Python 3.10 and cannot provide Python >= 3.3.
  - INFO: Executable: Not found

## Python virtualenv                                         - OK: no $VIRTUAL_ENV
解决办法

最简单的解决办法就是降级python3.10至低版本。

如果不想降级,就要修改nvim的文件了。 此bug 在2021年10月8日刚修复,目前发布的正式版本中还是存在此BUG的。

  • 升级此文件 https://github.com/neovim/neovim/blob/master/runtime/autoload/provider/pythonx.vim

我在termux中的nvim 0.5.1此配置文件的位置是:

/data/data/com.termux/files/usr/share/nvim/runtime/autoload/provider

普通的linux可以尝试在以下路径找找。

/usr/share/nvim/runtime/autoload/provider

替换此文件后,问题解决了。

## Python 3 provider (optional)                              
- INFO: `g:python3_host_prog` is not set.  Searching for   python3 in the environment.                                
- INFO: Executable: /data/data/com.termux/files/usr/bin/   python3                                                    - INFO: Python version: 3.10.0                             
- INFO: pynvim version: 0.4.3                              
- OK: Latest pynvim is installed.                                                                                   ## Python virtualenv                                         
- OK: no $VIRTUAL_ENV
参考

https://github.com/neovim/neovim/issues/14586

关注
打赏
1665243900
查看更多评论
立即登录/注册

微信扫码登录

0.0399s