Install & Compatibility
Where this runs
tested against v1.15.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.040s · 83.6MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 4.9s · import 0.038s · 86MB
80MB installed
● package 80MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
pylsp
✓ import pylsp
✗ from pylsp import main
The Python LSP Server is commonly launched by an editor/IDE as a subprocess. This quickstart demonstrates how to programmatically start the server, which then listens on stdin/stdout for Language Server Protocol messages. In a real application, an LSP client would handle sending and receiving these JSON-RPC messages.
import subprocess
import sys
import os
import time
import shutil
# The Python LSP Server is primarily meant to be run as a separate process
# and communicated with via stdin/stdout using the Language Server Protocol.
# This example shows how to launch it programmatically for testing or custom integration.
print("Launching python-lsp-server in a subprocess...")
try:
# Using `sys.executable -m pylsp` ensures the correct Python environment is used.
# We redirect stdout/stderr to pipes to prevent it from blocking the console.
# For real use, stdout would carry LSP messages to a client.
process = subprocess.Popen(
[sys.executable, '-m', 'pylsp', '--log-level', 'WARNING'], # Adjust log-level as needed
stdin=subprocess.PIPE, # Server expects LSP messages here
stdout=subprocess.PIPE, # Server sends LSP messages here
stderr=subprocess.PIPE, # Server logs errors/debug info here
text=True, # Handle stdin/stdout as text
bufsize=0 # Unbuffered I/O for real-time LSP communication
)
print("Server process started.")
print("It is now listening for LSP messages on stdin and sending responses on stdout.")
print("This process will block waiting for input unless a client sends messages.")
print("Waiting for 2 seconds to simulate runtime...")
time.sleep(2)
# In a real scenario, you would send JSON-RPC LSP messages here, e.g.,
# process.stdin.write('Content-Length: ...\r\n\r\n{"jsonrpc": "2.0", ...}\r\n')
# process.stdin.flush()
print("Attempting to terminate the server.")
process.terminate() # Send SIGTERM (or equivalent on Windows)
stdout, stderr = process.communicate(timeout=5) # Wait for it to exit and get output
print(f"\nServer exit code: {process.returncode}")
if stdout:
print("\n--- Server STDOUT (LSP messages) ---")
print(stdout.strip())
if stderr:
print("\n--- Server STDERR (Logs/Errors) ---")
print(stderr.strip())
except FileNotFoundError:
print(f"Error: `pylsp` command or `sys.executable` not found. Is python-lsp-server installed?")
except subprocess.TimeoutExpired:
print("Server did not terminate gracefully within the timeout. Killing it.")
process.kill()
stdout, stderr = process.communicate()
except Exception as e:
print(f"An error occurred: {e}")
finally:
print("Quickstart demonstration complete.")
pylsp --version
Upgrade
Version history
1.15.0latest on PyPI · released Jul 27, 2026
Audit
Dependencies
pylsp-ropeoptionalRequired for Rope-based refactoring features (e.g., rename) after `rope_rename` plugin was removed in v1.11.0.