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

Cannot start with "ModuleNotFoundError" after installing with "pip install esbonio[lsp]" #147

Closed
yaegassy opened this issue Apr 20, 2021 · 4 comments · Fixed by #148
Closed

Comments

@yaegassy
Copy link
Contributor

Reproduction Procedure (prepare)

mkdir -p /tmp/esbonio-check
cd /tmp/esbonio-check
python3 -m venv venv
source venv/bin/activate
pip install -U esbonio[lsp]

Error

(venv) esbonio-check$ python3 -m esbonio --help
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/private/tmp/esbonio-check/venv/lib/python3.9/site-packages/esbonio/__main__.py", line 5, in <module>
    import esbonio.lsp as lsp
  File "/private/tmp/esbonio-check/venv/lib/python3.9/site-packages/esbonio/lsp/__init__.py", line 10, in <module>
    from pygls.features import COMPLETION, INITIALIZE, INITIALIZED, TEXT_DOCUMENT_DID_SAVE
ModuleNotFoundError: No module named 'pygls.features'

It looks like "pygls" is "0.10.2"

(venv) esbonio-check$ pip freeze | grep pygls
pygls==0.10.2

Looking at this issue, it looks like 0.10.x is not yet supported. #144

You may need to adjust the package dependencies.

Misc

As a workaround, I set the pygls version to 0.9.x as shown below, and it started.

pip install -U esbonio[lsp] pygls==0.9.1
@alcarney
Copy link
Member

Thank you for such a detailed issue report!

I'm about to merge #148 which should result in esbonio v0.5.1 being released with this issue resolved. Feel free to re-open this issue if the problem persists.

yaegassy added a commit to yaegassy/coc-esbonio that referenced this issue Apr 20, 2021
@leosh64
Copy link

leosh64 commented Mar 6, 2023

A similar issue still persists with latest version of esbonio, this time the module attrs can't be found:

$ pip freeze | grep esbonio
esbonio==0.16.1

Python:

$ python --version
Python 3.10.6

Error:

$ python -m esbonio
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/user/.local/lib/python3.10/site-packages/esbonio/__main__.py", line 4, in <module>
    from esbonio import cli
  File "/home/user/.local/lib/python3.10/site-packages/esbonio/cli/__init__.py", line 7, in <module>
    from pygls.protocol import default_converter
  File "/home/user/.local/lib/python3.10/site-packages/pygls/protocol.py", line 32, in <module>
    import attrs
ModuleNotFoundError: No module named 'attrs'

But attrs is installed:

$ pip freeze | grep attrs
attrs==21.2.0
cattrs==22.2.0

The version of pygls is:

$ pip freeze | grep pygls
pygls==1.0.1

@alcarney
Copy link
Member

alcarney commented Mar 6, 2023

It looks like import attrs was only introduced in 21.3.0 (originally only import attr was available).
Upgrading your installation of attrs to at least that version should resolve the issue.

karthiknadig pushed a commit to microsoft/lsprotocol that referenced this issue Mar 6, 2023
`lsprotocol` uses the `import attrs` API which was only introduced in
[`v21.3.0`](https://www.attrs.org/en/stable/changelog.html#id7) .

This PR sets a minimum version for attrs in the python package's
`pyproject.toml` to hopefully guard against issues [like this
one](swyddfa/esbonio#147 (comment))
in the future.

**Question:** Is it sufficient to rely on the version bound set here to
ensure the correct version is also installed for `pygls` and `esbonio`?
Or since both downstream packages also `import attrs` themselves, is it
more correct to have a version bound set in both `pygls` and `esbonio`?
:thinking:
@leosh64
Copy link

leosh64 commented Mar 6, 2023

That fixes it, thanks!

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

Successfully merging a pull request may close this issue.

3 participants