Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoneType object has attribute plugin_manager #359

Open
wreed4 opened this issue May 24, 2018 · 12 comments
Open

NoneType object has attribute plugin_manager #359

wreed4 opened this issue May 24, 2018 · 12 comments

Comments

@wreed4
Copy link

wreed4 commented May 24, 2018

I just installed pyls to work with the oni editor. I don't think I've changed anything in the way of configuration. However, when I attempt to use the completion features, I always am met with this error. Here is the stack trace from stderr.

2018-05-24 15:53:51,397 UTC - ERROR - pyls.jsonrpc.endpoint - Failed to handle request 5
Traceback (most recent call last):
  File "/home/william/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pyls/jsonrpc/endpoint.py", line 113, in consume
    self._handle_request(message['id'], message['method'], message.get('params'))
  File "/home/william/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pyls/jsonrpc/endpoint.py", line 182, in _handle_request
    handler_result = handler(params)
  File "/home/william/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pyls/jsonrpc/dispatchers.py", line 23, in handler
    return method(**(params or {}))
  File "/home/william/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pyls/python_ls.py", line 239, in m_text_document__definition
    return self.definitions(textDocument['uri'], position)
  File "/home/william/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pyls/python_ls.py", line 174, in definitions
    return flatten(self._hook('pyls_definitions', doc_uri, position=position))
  File "/home/william/.pyenv/versions/3.6.3/lib/python3.6/site-packages/pyls/python_ls.py", line 112, in _hook
    hook_handlers = self.config.plugin_manager.subset_hook_caller(hook_name, self.config.disabled_plugins)
AttributeError: 'NoneType' object has no attribute 'plugin_manager'

Any help would be very much appreciated.

@wreed4
Copy link
Author

wreed4 commented May 25, 2018

never mind. I figured it out. I think. turns out oni is expecting me to install this with the [all] extras.. which I didn't want to do. There were errors above this about failing to import other modules. I'm not sure if that's the way oni is using this package or the package itself, but I'll close this issue anyways.

@wreed4 wreed4 closed this as completed May 25, 2018
@gatesn
Copy link
Contributor

gatesn commented May 26, 2018

@wreed4 are you still able to repro this issue? I’d be interesting in debugging it even if you’ve found a workaround.

@gatesn gatesn reopened this May 26, 2018
@wreed4
Copy link
Author

wreed4 commented May 30, 2018

@gatesn definitely. Install the Oni editor, then follow the instructions for setting up this plugin, but do not use the [all] directive. I believe I used rope and mccabe, but I think it will fail with any subset of all. Then open the developer tools under the help menu. Finally open a python file in the editor and you'll see a great many stack traces. eventually you find "module not found" exceptions if you scroll up.

@akahanaton
Copy link

akahanaton commented Sep 12, 2018

Hi
I got a similar problem in Neovim:

15:53:23 INFO reader-python src/vim.rs:392 <= Some("python") {"jsonrpc": "2.0", "id": 14, "error": {"code": -32602, "message": "AttributeError: 'NoneType' object has no attribute 'plugin_manager'", "data": {"traceback": ["  File \"/home/ming/.local/lib/python3.7/site-packag
es/jsonrpc/endpoint.py\", line 113, in consume\n    self._handle_request(message['id'], message['method'], message.get('params'))\n", "  File \"/home/ming/.local/lib/python3.7/site-packages/jsonrpc/endpoint.py\", line 182, in _handle_request\n    handler_result = handler(pa
rams)\n", "  File \"/home/ming/.local/lib/python3.7/site-packages/jsonrpc/dispatchers.py\", line 23, in handler\n    return method(**(params or {}))\n", "  File \"/home/ming/.local/lib/python3.7/site-packages/pyls/python_ls.py\", line 260, in m_text_document__definition\n  
  return self.definitions(textDocument['uri'], position)\n", "  File \"/home/ming/.local/lib/python3.7/site-packages/pyls/python_ls.py\", line 192, in definitions\n    return flatten(self._hook('pyls_definitions', doc_uri, position=position))\n", "  File \"/home/ming/.local
/lib/python3.7/site-packages/pyls/python_ls.py\", line 116, in _hook\n    hook_handlers = self.config.plugin_manager.subset_hook_caller(hook_name, self.config.disabled_plugins)\n"]}}}
15:53:23 ERROR main src/vim.rs:59 Error handling message: AttributeError: 'NoneType' object has no attribute 'plugin_manager'

Error: ErrorMessage { msg: "AttributeError: \'NoneType\' object has no attribute \'plugin_manager\'" }
15:53:23 INFO main src/vim.rs:92 => None {"jsonrpc":"2.0","error":{"code":-32603,"message":"AttributeError: 'NoneType' object has no attribute 'plugin_manager'"},"id":1}

The error occurs when I using go_to_definition function while set PYTHONPATH to include the local library path "~/.local/lib/python3.7/site-packages".

If exclude the local library in PYTHONPATH, then the go_to_definition works without error message. It can jumps to system libraries like 'os', but failed to jump to local libraries installed in
~/.local/lib/python3.7/site-packages , with an notification says 'Not found!'

I tried to reinstall the language server but without luck. any help please? Many thanks.

@akahanaton
Copy link

I installed the library outside the .local path and included the new path in PYTHONPATH, now the go_to_definition can jump to the new location now.

@dkasak
Copy link

dkasak commented Jul 11, 2019

This started happening to me recently. I didn't update pyls in the meantime. This was on version 0.26, on Arch Linux. I tried updating to 0.27 but it did not help.

@Bergiu
Copy link

Bergiu commented Jul 31, 2019

This started happening to me recently. I didn't update pyls in the meantime. This was on version 0.26, on Arch Linux. I tried updating to 0.27 but it did not help.

I had the same problem. I fixed it with uninstalling typed-ast version 1.4.0 and installing version 1.3.1:
sudo pip uninstall typed-ast && sudo pip install typed-ast==1.3.1

@Penaz91
Copy link

Penaz91 commented Aug 13, 2019

I'm having a similar problem, I'm using Artix Linux and NeoVim 0.3.8, this is the output of :messages after using the "Definition" feature of languageclient-neovim:

[LC] Error: Failure { jsonrpc: Some(V2), error: Error { code: InvalidParams, message: "AttributeError: \'NoneType\' object has no attribute \'plugin_manager\'", data: Some(Object({"traceback
": Array([String("  File \"/usr/lib/python3.7/site-packages/pyls_jsonrpc/endpoint.py\", line 113, in consume\n    self._handle_request(message[\'id\'], message[\'method\'], message.get(\'par
ams\'))\n"), String("  File \"/usr/lib/python3.7/site-packages/pyls_jsonrpc/endpoint.py\", line 182, in _handle_request\n    handler_result = handler(params)\n"), String("  File \"/usr/lib/p
ython3.7/site-packages/pyls_jsonrpc/dispatchers.py\", line 23, in handler\n    return method(**(params or {}))\n"), String("  File \"/usr/lib/python3.7/site-packages/pyls/python_ls.py\", lin
e 296, in m_text_document__definition\n    return self.definitions(textDocument[\'uri\'], position)\n"), String("  File \"/usr/lib/python3.7/site-packages/pyls/python_ls.py\", line 221, in d
efinitions\n    return flatten(self._hook(\'pyls_definitions\', doc_uri, position=position))\n"), String("  File \"/usr/lib/python3.7/site-packages/pyls/python_ls.py\", line 129, in _hook\n 
   hook_handlers = self.config.plugin_manager.subset_hook_caller(hook_name, self.config.disabled_plugins)\n")])})) }, id: Num(2) }

I would like to avoid using pip install on the system since my package manager should take care of it.
I'll try using pacman to downgrade to typed-ast 1.3.1 as Bergiu suggested. I'll keep you updated.

Update: Downgrading to python-typed-ast 1.3.1 using pacman doesn't seem to work.

@Penaz91
Copy link

Penaz91 commented Aug 14, 2019

Update: Seems that the problem (in my case) is due to the mypy extension requiring python-typing_extension version 3.7.4 or higher, while the most recent version on my system is 3.7.2.
Uninstalling the mypy extension for pyls solves the issue in my case.

@itsjef
Copy link

itsjef commented Aug 29, 2019

I didn't investigate the root cause but going back to version 0.26.0 fixed the issue. Remember to uninstall your current installation of python-language-server first.

@Zebradil
Copy link

Zebradil commented Sep 2, 2019

Installing mypy and black solved this issue for me:

pip install --user mypy black

PyLS is installed as user's package:

pip install --user 'python-language-server[all]'
black                  19.3b0
mypy                   0.720
mypy-extensions        0.4.1
python-language-server 0.28.2

@racko
Copy link

racko commented Oct 17, 2020

tl;dr
Check whether AttributeError: 'NoneType' object has no attribute 'plugin_manager' really is the first error in your log.

Update
I found that vim-lsp has code to react to server initialization failure and wanted to figure out why it isn't invoked. After instrumenting the code I found the following beautiful error message in the vim :messages:

Failed to initialize pyls-all with error -32602: configparser.MissingSectionHeaderError: File contains no section headers.^@file: '/home/racko/.config/pycode
style', line: 2^@'enabled: true\n'

It was always there, I just didn't look. I wondered why it didn't show up in the status bar. Then I realized that, to debug an earlier problem, I added an "lsp_buffer_enabled" message, which replaced the earlier message from pyls 🙄


Hi,
in my case I realized that AttributeError: 'NoneType' object has no attribute 'plugin_manager' was not the first error. pyls failed to load my pycodestyle config: configparser.MissingSectionHeaderError: File contains no section headers.", "file: '/home/racko/.config/pycodestyle', line: 1\n'\"pyls.plugins.pydocstyle.enabled\": true\\n'". Which was missing section headers because I didn't know what I was doing when I tried to follow the advice in the README:

To enable pydocstyle for linting docstrings add the following setting in your LSP configuration: "pyls.plugins.pydocstyle.enabled": true

So, I guess that the reports in this issue have in common that some error occurred and pyls didn't gracefully handle it? After the error it was not initialize because the initialize request was missing? Is that an error of pyls or of the client/editor? (vim-lsp in my case)

I see the following communication in the vim-lsp/pyls debug output:

  1. Sat 17 Oct 2020 10:17:27 PM CEST:["Starting server", "pyls-all" ...
  2. Sat 17 Oct 2020 10:17:27 PM CEST:[{"response": {"data": {"__data__": "vim-lsp", "lsp_id": 3, "server_name": "pyls-all"}, "message": "started lsp server successfully"}}]
  3. Sat 17 Oct 2020 10:17:27 PM CEST:["--->", 3, "pyls-all", {"method": "initialize" ...
  4. Sat 17 Oct 2020 10:17:27 PM CEST:["<---(stderr)", 3, "pyls-all", ["2020-10-17 22:17:27,450 UTC - ERROR - pyls_jsonrpc.endpoint - Failed to handle request 1", "Traceback (most recent call last) ...
  5. Sat 17 Oct 2020 10:17:27 PM CEST:["<---", 3, "pyls-all", {"response": {"id": 1, "jsonrpc": "2.0", "error": ..."code": -32602, "message": "configparser.MissingSectionHeaderError..."...}, "request": {..."method": "initialize"...}}]
  6. Sat 17 Oct 2020 10:17:27 PM CEST:["--->", 3, "pyls-all", {"method": "initialized", "params": {}}]
  7. Sat 17 Oct 2020 10:17:27 PM CEST:["<---(stderr)", 3, "pyls-all", ["2020-10-17 22:17:27,454 UTC - ERROR - pyls_jsonrpc.endpoint - Failed to handle notification initialized: {}", "Traceback (most recent call last):", " File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-pack ages/pyls_jsonrpc/endpoint.py\", line 142, in _handle_notification", " handler_result = handler(params)", " File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls_jsonrpc/dispatchers.py\", line 23, in handler", " return method(**(params or {}))", " File \ "/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls/python_ls.py\", line 231, in m_initialized", " self._hook('pyls_initialized')", " File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls/python_ls.py\", line 155 , in _hook", " hook_handlers = self.config.plugin_manager.subset_hook_caller(hook_name, self.config.disabled_plugins)", "AttributeError: 'NoneType' object has no attribute 'plugin_manager'", ""]]
"Traceback (most recent call last):",
"  File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls_jsonrpc/endpoint.py\", line 113, in consume",
"    self._handle_request(message['id'], message['method'], message.get('params'))",
"  File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls_jsonrpc/endpoint.py\", line 182, in _handle_request",
"    handler_result = handler(params)",
"  File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls_jsonrpc/dispatchers.py\", line 23, in handler",
"    return method(**(params or {}))",
"  File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls/python_ls.py\", line 208, in m_initialize",
"    self.config = config.Config(rootUri, initializationOptions or {},",
"  File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls/config/config.py\", line 68, in __init__",
"    self._update_disabled_plugins()",
"  File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls/config/config.py\", line 153, in _update_disabled_plugins",
"    self._disabled_plugins = [",
"  File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls/config/config.py\", line 155, in <listcomp>",
"    if not self.settings().get('plugins', {}).get(name, {}).get('enabled', True)",
"  File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls/config/config.py\", line 120, in settings",
"    source_conf = source.user_config()",
"  File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls/config/pycodestyle_conf.py\", line 25, in user_config",
"    config = self.read_config_from_files(USER_CONFIGS)",
"  File \"/home/racko/.local/share/vim-lsp-settings/servers/pyls-all/venv/lib/python3.8/site-packages/pyls/config/source.py\", line 33, in read_config_from_files",
"    config.read(filename)",
"  File \"/usr/lib/python3.8/configparser.py\", line 697, in read",
"    self._read(fp, filename)",
"  File \"/usr/lib/python3.8/configparser.py\", line 1082, in _read",
"    raise MissingSectionHeaderError(fpname, lineno, line)",
"configparser.MissingSectionHeaderError: File contains no section headers.",
"file: '/home/racko/.config/pycodestyle', line: 1\n'\"pyls.plugins.pydocstyle.enabled\": true\\n'"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants