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

现象

最近把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的。

我在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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值