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

2023-05-16

现象

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

nvim 0.5.1不支持python3.10排错笔记 的相关文章

随机推荐