Closed gptlang closed 9 months ago
That seems like a bug in importlib
? Does it work on later python versions?
Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/pynvim/plugin/host.py", line 193, in _load module = _handle_import(directory, name)
That seems like an out of date package. Maybe there are changes on master that weren't release yet. Here's line 193:
That seems like a bug in importlib? Does it work on later python versions?
Yes. Works on later versions. I'm pretty sure importlib is standard library though; it shouldn't be out of date
I mean that your pynvim source is out of date compared to pynvim master
(can you try that)?
pip install git+https://github.com/neovim/pynvim
?
CC @Cassius0924
Edit: oops, wrong account
git install git+https://github.com/neovim/pynvim
?CC @Cassius0924
Edit: oops, wrong account
It seems like there's a small mistake in your command. It's pip install
not git install
.
I used pip install git+https://github.com/neovim/pynvim
to upgrade the pynvim version to 0.5.0.dev0, but there are still errors, but the error line has changed from line 193
to line 187
Encountered TypeError loading plugin at /root/.local/share/lunarvim/site/pack/lazy/opt/CopilotChat.nvim/rplugin/python3/utilities.py: 'type' object is not subscriptable
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/pynvim/plugin/host.py", line 187, in _load
module = _handle_import(directory, name)
File "/usr/local/lib/python3.8/dist-packages/pynvim/plugin/host.py", line 40, in _handle_import
return importlib.import_module(name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
TypeError: 'type' object is not subscriptable
remote/host: python3 host registered plugins []
remote/host: generated rplugin manifest: /root/.local/share/lvim/rplugin.vim
It seems like there's a small mistake in your command. It's pip install not git install.
Yup. Typo
Could you try to reproduce this with a minimal Python file by importing importlib
and calling it?
Like below?
I wrote a Python file:
import importlib
import sys
sys.path.append(
"/root/.local/share/lunarvim/site/pack/lazy/opt/CopilotChat.nvim/rplugin/python3"
)
def test_import(name):
importlib.import_module(name)
test_import("copilot")
Still getting error after running:
Traceback (most recent call last):
File "t_1.py", line 17, in <module>
test_import("copilot")
File "t_1.py", line 11, in test_import
importlib.import_module(name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/root/.local/share/lunarvim/site/pack/lazy/opt/CopilotChat.nvim/rplugin/python3/copilot.py", line 10, in <module>
import utilities
File "/root/.local/share/lunarvim/site/pack/lazy/opt/CopilotChat.nvim/rplugin/python3/utilities.py", line 13, in <module>
chat_history: list[typings.Message],
TypeError: 'type' object is not subscriptable
This error seems not to be from pynvim, but from CopilotChat. I tried replacing list
with List
and it worked normally.
Ah I see. I suppose I got confused by the error output
Yes, the error was coming from the rplugin code, but the error message printed in Nvim can be confusing. We can improve error messages to clearly indicate that the SyntaxError/RuntimeError originates from the remote plugin.
Reference: https://github.com/gptlang/CopilotChat.nvim/issues/18