Python LSP Configuration

The details below describe how to install and configure the Python language server found here.
NOTE: This installation process assumes a full version of Python has been installed on the machine.

Installing the Language Server

To install the language server run the following command:
pip install python-language-server
With the software installed test the installation by running pyls -h at the command line prompt, which should result in the following output:
usage: pyls [-h] [--tcp] [--host HOST] [--port PORT]
            [--log-config LOG_CONFIG | --log-file LOG_FILE] [-v]

Python Language Server

optional arguments:
  -h, --help            show this help message and exit
  --tcp                 Use TCP server instead of stdio
  --host HOST           Bind to this address
  --port PORT           Bind to this port
  --log-config LOG_CONFIG
                        Path to a JSON file containing Python logging config.
  --log-file LOG_FILE   Redirect logs to the given file instead of writing to
                        stderr.Has no effect if used with --log-config.
  -v, --verbose         Increase verbosity of log output, overrides log config
                        file
If that output is not produced check the installation and also check to make sure the installation folder has been added to the system PATH environment variable.

Server Batch File

Because Zeus itself can be scripted using the Python language the Zeus installation includes a cut down version of the Python interpreter.
However, the Python Language Server requires a full version of Python and as such a batch file is needed to ensure these two versions of Python can run side by side.
Create the following zLSP.cmd batch file, taking note of the folder location of the file as that information will be needed in a later configuration step:
@echo off

:: Point to the full Python installation
set PATH=C:\Python37\;%PATH%
set PYTHONPATH=C:\Python37\Lib

cd C:\Python37\Scripts\

:: Echo the command about to be run
echo pyls.exe --log-file=%temp%\python_lsp.log --verbose

:: Run the language server writing the log file to the temp folder
pyls.exe --log-file=%temp%\python_lsp.log --verbose
NOTE: The details found in this batch file may need to be adjusted to suit the local machine. For example the Python installation folder or the version of Python installed may need to be adjusted.

Configuration

Edit the Python document type and in the Language Server configuration panel apply the following configuration settings:
Program Type: Batch
     Program: zLSP.cmd
   Directory: The folder location of the zLSP.cmd file

Using the Language Server

To test the configuration create a simple test.py file and fire off an auto-complete request:
lsp python


Latest Version: Zeus 3.98s
Released: 9th November 2018