davidhalter / jedi

Awesome autocompletion, static analysis and refactoring library for python
http://jedi.readthedocs.io
Other
5.73k stars 503 forks source link

Jedi outputs: Syntax Error Invalid Syntax #1999

Closed ghsanti closed 1 month ago

ghsanti commented 1 month ago

I'm trying to use Jedi in a conda environment, with python 3.12

I get this output in the console for VSCode:

2024-06-13 13:42:39.750 [info] [Error - 13:42:39] Server process exited with code 1.
2024-06-13 13:42:39.810 [info] Traceback (most recent call last):
  File "/.vscode-server/extensions/ms-python.python-2024.8.0/python_files/run-jedi-language-server.py", line 9, in <module>
    from jedi_language_server.cli import cli  # noqa: E402
  File "/.vscode-server/extensions/ms-python.python-2024.8.0/python_files/lib/jedilsp/jedi_language_server/__init__.py", line 5, in <module>
    from importlib_metadata import version
  File "/.vscode-server/extensions/ms-python.python-2024.8.0/python_files/lib/jedilsp/importlib_metadata/__init__.py", line 6, in <module>
    import zipp
  File "/.vscode-server/extensions/ms-python.python-2024.8.0/python_files/lib/jedilsp/zipp/__init__.py", line 9, in <module>
    from .py310compat import text_encoding
  File "/.vscode-server/extensions/ms-python.python-2024.8.0/python_files/lib/jedilsp/zipp/py310compat.py", line 5
    def _text_encoding(encoding, stacklevel=2, /):  # pragma: no cover
                                               ^
SyntaxError: invalid syntax

2024-06-13 13:42:39.821 [info] [Error - 13:42:39] Server initialization failed.
2024-06-13 13:42:39.822 [info]   Message: Pending response rejected since connection got disposed
  Code: -32097 

How to fix it?

davidhalter commented 1 month ago

This is an error in jedilsp (not Jedi). Since this is caused by positional only params (https://peps.python.org/pep-0570/), I assume you are using a Python version before 3.8, which is probably unsupported. So just use a more recent Python version.

ghsanti commented 1 month ago

This is an error in jedilsp (not Jedi). Since this is caused by positional only params (https://peps.python.org/pep-0570/), I assume you are using a Python version before 3.8, which is probably unsupported. So just use a more recent Python version.

you are right, thank you, runs perfectly now.