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

AttributeError: 'PosixPath' object has no attribute 'read_text' #938

Open
evandrocoan opened this issue Jun 8, 2021 · 2 comments
Open

Comments

@evandrocoan
Copy link
Contributor

evandrocoan commented Jun 8, 2021

2021-06-08 16:35:25,856 UTC - INFO - pyls.python_ls - Starting PythonLanguageServer IO language server
2021-06-08 16:35:25,856 UTC - DEBUG - pyls_jsonrpc.endpoint - Handling request from client {'params': {'processId': 3768692, 'rootPath': '/home/evandro_coan/maquinas/x_files', 'capabilities': {'textDocument': {'completion': {'completionItemKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]}, 'completionItem': {'snippetSupport': True}}, 'documentSymbol': {'symbolKind': {'valueSet': [1, 2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14]}}, 'references': {}, 'synchronization': {'didSave': True}, 'definition': {}, 'signatureHelp': {'signatureInformation': {'documentationFormat': ['markdown', 'plaintext']}}, 'rangeFormatting': {}, 'documentHighlight': {}, 'rename': {}, 'codeAction': {}, 'hover': {'contentFormat': ['markdown', 'plaintext']}, 'formatting': {}}, 'workspace': {'didChangeConfiguration': {}, 'applyEdit': True}}, 'rootUri': 'file:///home/evandro_coan/maquinas/x_files'}, 'id': 1, 'jsonrpc': '2.0', 'method': 'initialize'}
2021-06-08 16:35:25,857 UTC - DEBUG - pyls.python_ls - Language server initialized with 3768692 file:///home/evandro_coan/maquinas/x_files /home/evandro_coan/maquinas/x_files None
2021-06-08 16:35:25,931 UTC - WARNING - pyls.config.config - Failed to load pyls entry point 'autopep8': No module named 'pycodestyle'
2021-06-08 16:35:25,946 UTC - WARNING - pyls.config.config - Failed to load pyls entry point 'pycodestyle': No module named 'pycodestyle'
2021-06-08 16:35:25,947 UTC - WARNING - pyls.config.config - Failed to load pyls entry point 'pydocstyle': No module named 'pydocstyle'
2021-06-08 16:35:25,948 UTC - WARNING - pyls.config.config - Failed to load pyls entry point 'pyflakes': No module named 'pyflakes'
2021-06-08 16:35:25,950 UTC - WARNING - pyls.config.config - Failed to load pyls entry point 'rope_completion': No module named 'rope'
2021-06-08 16:35:25,952 UTC - WARNING - pyls.config.config - Failed to load pyls entry point 'rope_rename': No module named 'rope'
2021-06-08 16:35:25,952 UTC - WARNING - pyls.config.config - Failed to load pyls entry point 'yapf': No module named 'yapf'
2021-06-08 16:35:25,966 UTC - ERROR - pyls_jsonrpc.endpoint - Failed to handle request 1
Traceback (most recent call last):
  File "/home/evandro_coan/.local/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/evandro_coan/.local/lib/python3.8/site-packages/pyls_jsonrpc/endpoint.py", line 182, in _handle_request
    handler_result = handler(params)
  File "/home/evandro_coan/.local/lib/python3.8/site-packages/pyls_jsonrpc/dispatchers.py", line 23, in handler
    return method(**(params or {}))
  File "/home/evandro_coan/.local/lib/python3.8/site-packages/pyls/python_ls.py", line 208, in m_initialize
    self.config = config.Config(rootUri, initializationOptions or {},
  File "/home/evandro_coan/.local/lib/python3.8/site-packages/pyls/config/config.py", line 59, in __init__
    self._pm.load_setuptools_entrypoints(PYLS)
  File "/usr/local/lib/python3.8/dist-packages/pluggy/manager.py", line 290, in load_setuptools_entrypoints
    for ep in dist.entry_points:
  File "/usr/lib/python3.8/importlib/metadata.py", line 240, in entry_points
    return EntryPoint._from_text(self.read_text('entry_points.txt'))
  File "/usr/lib/python3.8/importlib/metadata.py", line 491, in read_text
    return self._path.joinpath(filename).read_text(encoding='utf-8')
AttributeError: 'PosixPath' object has no attribute 'read_text'

These are the lines. From the log, it had this problem after processing PYLS==yapf

File: /home/evandro_coan/.local/lib/python3.8/site-packages/pyls/config/config.py
48:         # Pluggy will skip loading a plugin if it throws a DistributionNotFound exception.
49:         # However I don't want all plugins to have to catch ImportError and re-throw. So here we'll filter
50:         # out any entry points that throw ImportError assuming one or more of their dependencies isn't present.
51:         for entry_point in pkg_resources.iter_entry_points(PYLS):
52:             try:
53:                 entry_point.load()
54:             except ImportError as e:
55:                 log.warning("Failed to load %s entry point '%s': %s", PYLS, entry_point.name, e)
56:                 self._pm.set_blocked(entry_point.name)
57: 
58:         # Load the entry points into pluggy, having blocked any failing ones
59:         self._pm.load_setuptools_entrypoints(PYLS)
@felixfrank
Copy link

Any idea how to fix this? I have the same issue.

@lieryan
Copy link

lieryan commented Sep 25, 2022

This repository is no longer maintained. The project now lives in python-lsp-server (pylsp), which is a maintained fork of python-language-server (pyls).

If you have projects still using pyls, you should update it to use pylsp instead.

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

3 participants