sublimelsp / LSP-pylsp

Convenience package for the Python Language Server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The virtual environment configured in the project does not work

thep0y opened this issue · comments

Configuration of my project:

{
	"folders": [
		{
			"path": "."
		}
	],
	"settings": {
		"LSP": {
			"LSP-pylsp": {
				"settings": {
					"pylsp.plugins.jedi.environment": "/Users/thepoy/venvs/spider"
				}
			}
		},
	}
}

Although there is no error or exception thrown, none of the packages in the virtual environment can be prompted or automatically completed.

Virtual environment directory structure:

.
├── bin
├── include
├── lib
│   └── python3.8
│       └── site-packages
└── share

It can be seen that it is a virtual environment generated by python3-venv.

Indeed the project overrides don't work as expected. They will work if you use the pylsp key instead of LSP-pylsp.

I'll see what I can do about that but probably will have to not override the LSP-pylsp name which is currently done so that only pylsp is shown in the status bar.

Hi @rchl - I don't believe #32 fixed this. I've confirmed that I can set my virtual environment via the package settings:

// User/LSP-pylsp.sublime-settings
{
    "settings": {
        "pylsp.plugins.jedi.environment": "./.venv/",

However, if I try to set this in the project config, it doesn't seem to be picked up. I've tried both:

    "settings": {
        "LSP": {
            "pylsp": {
                "settings": {
                    "pylsp.plugins.jedi.environment": "./.venv/"

and

    "settings": {
        "LSP": {
            "LSP-pylsp": {
                "settings": {
                    "pylsp.plugins.jedi.environment": "./.venv/"

Any ideas what I'm missing?

The last example matches expected structure.

Use that last example then open a file where you expect it to work and then run LSP: Troubleshoot server. Feel free to share those results.

LSP: Troubleshoot server doesn't seem to be available on the command palette. I'm guessing this is only available on the ST4 version of LSP? I'm still using ST3 due to some package incompatibilities.

Is there an alternate way to debug this? LSP-pylsp is running, it's just ignoring the project config. e.g., I can set "pylsp.plugins.pycodestyle.enabled": false, in pylsp's settings and it works, but setting this in the project config has no effect.

You may need to use “lsp-pylsp” instead of “LSP-pylsp” as the key in your .sublime-project. The key is the name of the client configuration, visible as a permanent status in the status bar.

        "LSP": {
            "lsp-pylsp": {

That seems to work. It might be worth mentioning in the docs? I've seen LSP-pylsp and pylsp suggested, but not lsp-pylsp for project settings.

Unfortunately, I'm having other issues with pylsp (e.g, flake8 doesn't always work? it worked once, but now I can't get it to run again?), so I've opted for a combination of sublimelinter-flake8 and lsp-pyright. Thanks for the help though.