swyddfa / esbonio

A language server for working with Sphinx projects.
https://docs.esbon.io/
135 stars 22 forks source link

Stopped working, says "ValueError: No Python Environment configured" #911

Open FrightRisk opened 1 month ago

FrightRisk commented 1 month ago

Expected behavior

Expect Esbonio and its preview to works as it has. Nothing happens when I open the preview window at all except for the box saying "No content found"

Actual behavior

Preview windows says "no content found" and a popup in VSC says "ValueError: No Python Environment configured". I am using the same steps that have been working.

Windows 11, batch file creates a Venv and builds the website as usual. I go back into the run commands menu and deselect the python version and reselect it (my venv version) and restart the Esbonio server. It fills the log below. I could only upload a small percentage of the log because it is too long for github (greater than 65536 characters)

I did not update anything that I know of and am sure to run a requirements.txt file with the versions of everything I was using since the most recent versions of some things broke Esbonio. This is the only warning I see creating the venv and building the website (which builds correctly)

"WARNING: The candidate selected for download or install is a yanked version: 'requests' candidate (version 2.32.0 at https://files.pythonhosted.org/packages/24/e8/09e8d662a9675a4e4f5dd7a8e6127b463a091d2703ed931a64aa66d00065/requests-2.32.0-py3-none-any.whl (from https://pypi.org/simple/requests/) (requires-python:>=3.8)) Reason for being yanked: Yanked due to conflicts with CVE-2024-35195 mitigation". Log of Esbonio when I try to run it is below. Using v2024.17.2024100701 (pre-release) version of Microsoft's Python. I will try an older version. The release version did not work last time.

Log output

[client] Unable to resolve command lsp-devtools: Error: Command failed: command -v lsp-devtools
'command' is not recognized as an internal or external command,
operable program or batch file.

[client] Using environment C:\USERS\FRED\DOCUMENTS\PLATFORMIO\PROJECTS\DCC-EX.GITHUB.IO\VENV\SCRIPTS\PYTHON.EXE: C:\Users\Fred\Documents\PlatformIO\Projects\dcc-ex.github.io\venv\Scripts\python.exe
[client] Server start command: c:\Users\Fred\Documents\PlatformIO\Projects\dcc-ex.github.io\venv\Scripts\python.exe -S -m esbonio.server
[client] LanguageClientOptions: {
  "documentSelector": [
    {
      "scheme": "file",
      "language": "restructuredtext"
    },
    {
      "scheme": "file",
      "language": "markdown"
    }
  ],
  "outputChannel": {
    "name": "Esbonio"
  },
  "connectionOptions": {
    "maxRestartCount": 0
  },
  "middleware": {
    "workspace": {},
    "window": {}
  }
}
[client] Starting Language Server
[client] sphinx/clientCreated: {
  "buildCommand": [
    "sphinx-build",
    "-M",
    "dirhtml",
    "c:\\Users\\Fred\\Documents\\PlatformIO\\Projects\\dcc-ex.github.io\\docs",
    "C:\\Users\\Fred\\AppData\\Local\\swyddfa\\esbonio\\Cache\\c7a65f76c715c9fee33c41e6aadc2eba"
  ],
  "cwd": "c:\\Users\\Fred\\Documents\\PlatformIO\\Projects\\dcc-ex.github.io",
  "pythonPath": [
    "c:\\Users\\Fred\\.vscode\\extensions\\swyddfa.esbonio-0.95.2\\bundled\\libs\\esbonio"
  ]
}
[esbonio] Loaded extension 'esbonio.server.features.log'
[esbonio] Loaded extension 'esbonio.server.features.project_manager'
[esbonio] Loaded extension 'esbonio.server.features.sphinx_manager'
[esbonio] Loaded extension 'esbonio.server.features.preview_manager'
[esbonio] Loaded extension 'esbonio.server.features.directives'
[esbonio] Loaded extension 'esbonio.server.features.roles'
[esbonio] Loaded extension 'esbonio.server.features.rst.directives'
[esbonio] Loaded extension 'esbonio.server.features.rst.roles'
[esbonio] Loaded extension 'esbonio.server.features.myst.directives'
[esbonio] Loaded extension 'esbonio.server.features.myst.roles'
[esbonio] Loaded extension 'esbonio.server.features.sphinx_support.diagnostics'
[esbonio] Loaded extension 'esbonio.server.features.sphinx_support.symbols'
[esbonio] Loaded extension 'esbonio.server.features.sphinx_support.directives'
[esbonio] Loaded extension 'esbonio.server.features.sphinx_support.roles'
[esbonio] Initialising esbonio v1.0.0b7, using Python v3.10.11 on Windows-10
[esbonio] Language client: Visual Studio Code 1.94.0
[esbonio.Configuration] Looking for pyproject.toml files in: 'c:\Users\Fred\Documents\PlatformIO\Projects\dcc-ex.github.io'
[esbonio.Configuration] workspace/configuration: {
  "items": [
    {
      "section": "esbonio"
    },
    {
      "scopeUri": "file:///c%3A/Users/Fred/Documents/PlatformIO/Projects/dcc-ex.github.io",
      "section": "esbonio"
    }
  ]
}
[esbonio.SphinxManager] No client found, creating new subscription
[esbonio.ProjectManager] No applicable project for uri: file:///c%3A/Users/Fred/Documents/PlatformIO/Projects/dcc-ex.github.io/docs/ex-csb1/index.rst
[esbonio.ProjectManager] No applicable project for uri: file:///c%3A/Users/Fred/Documents/PlatformIO/Projects/dcc-ex.github.io/docs/ex-csb1/index.rst
[esbonio.Configuration] Workspace 'None' configuration: {
  "server": {
    "enabled": true,
    "documentSelector": [],
    "startupModule": "esbonio.server",
    "excludedModules": [],
    "includedModules": [],
    "completion": {
      "preferredInsertBehavior": "replace"
    },
    "enableDevTools": false,
    "debug": false,
    "showDeprecationWarnings": false,
    "logLevel": "debug"
  },
  "sphinx": {
    "enableDevTools": false,
    "pythonPath": []
  },
  "preview": {
    "showLineMarkers": false
  },
  "logging": {
    "level": "debug",
    "stderr": true,
    "window": true,
    "config": {}
  },
  "trace": {
    "server": "off"
  }
}
[esbonio.Configuration] Workspace 'file:///c%3A/Users/Fred/Documents/PlatformIO/Projects/dcc-ex.github.io' configuration: {
  "server": {
    "enabled": true,
    "documentSelector": [],
    "startupModule": "esbonio.server",
    "excludedModules": [],
    "includedModules": [],
    "completion": {
      "preferredInsertBehavior": "replace"
    },
    "enableDevTools": false,
    "debug": false,
    "showDeprecationWarnings": false,
    "logLevel": "debug"
  },
  "sphinx": {
    "enableDevTools": false,
    "pythonPath": []
  },
  "preview": {
    "showLineMarkers": false
  },
  "logging": {
    "level": "debug",
    "stderr": true,
    "window": true,
    "config": {}
  },
  "trace": {
    "server": "off"
  }
}
[esbonio.Configuration] ConfigurationContext(file_scope='', workspace_scope='file:///c%3A/Users/Fred/Documents/PlatformIO/Projects/dcc-ex.github.io')
[esbonio.Configuration] esbonio.sphinx: {
  "enableDevTools": false,
  "pythonPath": []
}
[esbonio.Configuration] SphinxConfig(enable_dev_tools=False, python_command=[], build_command=[], config_overrides={}, env_passthrough=[], cwd='c:\\Users\\Fred\\Documents\\PlatformIO\\Projects\\dcc-ex.github.io', python_path=[])
[esbonio.Configuration] Previous: None
[esbonio.Configuration] Current: SphinxConfig(enable_dev_tools=False, python_command=[], build_command=[], config_overrides={}, env_passthrough=[], cwd='c:\\Users\\Fred\\Documents\\PlatformIO\\Projects\\dcc-ex.github.io', python_path=[])
[esbonio.Configuration] ConfigChangeEvent(scope='file:///c%3A/Users/Fred/Documents/PlatformIO/Projects/dcc-ex.github.io', value=SphinxConfig(enable_dev_tools=False, python_command=[], build_command=[], config_overrides={}, env_passthrough=[], cwd='c:\\Users\\Fred\\Documents\\PlatformIO\\Projects\\dcc-ex.github.io', python_path=[]), previous=None)
[esbonio] Scheduled task: <Task finished name='Task-12' coro=<SphinxManager._create_or_replace_client() done, defined at c:\Users\Fred\.vscode\extensions\swyddfa.esbonio-0.95.2\bundled\libs\esbonio\server\features\sphinx_manager\manager.py:251> result=None>
[esbonio.SphinxManager] Trying path: c:\Users\Fred\Documents\PlatformIO\Projects\dcc-ex.github.io\docs\ex-csb1
[esbonio.SphinxManager] Trying path: c:\Users\Fred\Documents\PlatformIO\Projects\dcc-ex.github.io\docs
[esbonio.SphinxManager] Cwd: c:\Users\Fred\Documents\PlatformIO\Projects\dcc-ex.github.io
[esbonio.SphinxManager] Build command: ['sphinx-build', '-M', 'dirhtml', 'c:\\Users\\Fred\\Documents\\PlatformIO\\Projects\\dcc-ex.github.io\\docs', 'C:\\Users\\Fred\\AppData\\Local\\swyddfa\\esbonio\\Cache\\c7a65f76c715c9fee33c41e6aadc2eba']
[esbonio.SphinxManager] Client created for scope file:///c%3A/Users/Fred/Documents/PlatformIO/Projects/dcc-ex.github.io
[esbonio.SphinxManager] SphinxClient[08d41611-80e2-4c3c-b445-bc92442c8575]: None -> ClientState.Starting
[esbonio.SphinxManager] Unable to start SphinxClient: No python environment configured
Traceback (most recent call last):
  File "c:\Users\Fred\.vscode\extensions\swyddfa.esbonio-0.95.2\bundled\libs\esbonio\server\features\sphinx_manager\client_subprocess.py", line 206, in start
    command = get_start_command(self.config, self.logger)
  File "c:\Users\Fred\.vscode\extensions\swyddfa.esbonio-0.95.2\bundled\libs\esbonio\server\features\sphinx_manager\client_subprocess.py", line 358, in get_start_command
    raise ValueError("No python environment configured")
ValueError: No python environment configured
[esbonio.SphinxManager] SphinxClient[08d41611-80e2-4c3c-b445-bc92442c8575]: ClientState.Starting -> ClientState.Errored
[esbonio] Task finished: <Task finished name='Task-12' coro=<SphinxManager._create_or_replace_client() done, defined at c:\Users\Fred\.vscode\extensions\swyddfa.esbonio-0.95.2\bundled\libs\esbonio\server\features\sphinx_manager\manager.py:251> result=None>
[esbonio] Registered 'workspace/didChangeConfiguration' handler
[esbonio] Registered 'workspace/didChangeWatchedFiles' handler
[esbonio.Configuration] ConfigurationContext(file_scope='', workspace_scope='file:///c%3A/Users/Fred/Documents/PlatformIO/Projects/dcc-ex.github.io')
[esbonio.Configuration] esbonio.sphinx: {
  "enableDevTools": false,
  "pythonPath": []
}
[esbonio.Configuration] SphinxConfig(enable_dev_tools=False, python_command=[], build_command=[], config_overrides={}, env_passthrough=[], cwd='c:\\Users\\Fred\\Documents\\PlatformIO\\Projects\\dcc-ex.github.io', python_path=[])
[esbonio.Configuration] Previous: SphinxConfig(enable_dev_tools=False, python_command=[], build_command=[], config_overrides={}, env_passthrough=[], cwd='c:\\Users\\Fred\\Documents\\PlatformIO\\Projects\\dcc-ex.github.io', python_path=[])
[esbonio.Configuration] Current: SphinxConfig(enable_dev_tools=False, python_command=[], build_command=[], config_overrides={}, env_passthrough=[], cwd='c:\\Users\\Fred\\Documents\\PlatformIO\\Projects\\dcc-ex.github.io', python_path=[])
[esbonio.Configuration] ConfigurationContext(file_scope='', workspace_scope='')
[esbonio.Configuration] esbonio.logging: {
  "level": "debug",
  "stderr": true,
  "config": {},
  "window": true
}
[esbonio.Configuration] LoggingConfig(level='debug', format='[%(name)s] %(message)s', filepath=None, stderr=True, window=True, config={}, show_deprecation_warnings=False)
[esbonio.Configuration] Previous: None
[esbonio.Configuration] Current: LoggingConfig(level='debug', format='[%(name)s] %(message)s', filepath=None, stderr=True, window=True, config={}, show_deprecation_warnings=False)
[esbonio.Configuration] ConfigChangeEvent(scope='', value=LoggingConfig(level='debug', format='[%(name)s] %(message)s', filepath=None, stderr=True, window=True, config={}, show_deprecation_warnings=False), previous=None)
[esbonio.Configuration] ConfigurationContext(file_scope='', workspace_scope='')
[esbonio.Configuration] esbonio.preview: {
  "showLineMarkers": false
}
[esbonio.Configuration] PreviewConfig(bind='localhost', http_port=0, ws_port=0, show_line_markers=False)
[esbonio.Configuration] Previous: None
[esbonio.Configuration] Current: PreviewConfig(bind='localhost', http_port=0, ws_port=0, show_line_markers=False)
[esbonio.Configuration] ConfigChangeEvent(scope='', value=PreviewConfig(bind='localhost', http_port=0, ws_port=0, show_line_markers=False), previous=None)
[esbonio] Loaded extension 'esbonio.server.features.log'
[esbonio] Scheduled task: <Task pending name='Task-14' coro=<PreviewManager.show_preview_uri() running at c:\Users\Fred\.vscode\extensions\swyddfa.esbonio-0.95.2\bundled\libs\esbonio\server\features\preview_manager\__init__.py:181>>
[esbonio.Configuration] ConfigurationContext(file_scope='', workspace_scope='')
[esbonio.Configuration] esbonio.server.completion: {
  "preferredInsertBehavior": "replace"
}
[esbonio.Configuration] CompletionConfig(preferred_insert_behavior='replace')
[esbonio.Configuration] Previous: None
[esbonio.Configuration] Current: CompletionConfig(preferred_insert_behavior='replace')
[esbonio.Configuration] ConfigChangeEvent(scope='', value=CompletionConfig(preferred_insert_behavior='replace'), previous=None)
[esbonio.Configuration] ConfigurationContext(file_scope='', workspace_scope='')
[esbonio.Configuration] esbonio.server.completion: {
  "preferredInsertBehavior": "replace"
}

(Optional) Settings from conf.py

No response

FrightRisk commented 1 month ago

If it helps, this is the result of manually running a command I saw in the log:

(venv) C:\Users\Fred\Documents\PlatformIO\Projects\dcc-ex.github.io\venv>python.exe -S -m esbonio.server
C:\Users\Fred\Documents\PlatformIO\Projects\dcc-ex.github.io\venv\Scripts\python.exe: Error while finding module specification for 'esbonio.server' (ModuleNotFoundError: No module named 'esbonio')

And this is my requirements.txt file:

ablog==0.11.8
alabaster==0.7.14
apeye==1.3.0
apeye-core==1.1.2
autodocsumm==0.2.12
Babel==2.12.1
beautifulsoup4==4.12.2
CacheControl==0.12.11
certifi==2023.7.22
charset-normalizer==3.1.0
colorama==0.4.6
cssutils==2.6.0
dict2css==0.3.0
docutils==0.18.1
domdf-python-tools==3.6.1
feedgen==0.9.0
html5lib==1.1
idna==3.7
imagesize==1.4.1
invoke==2.0.0
Jinja2==3.1.4
lockfile==0.12.2
lxml==4.9.2
MarkupSafe==2.1.2
msgpack==1.0.5
natsort==8.3.1
packaging==23.1
platformdirs==3.2.0
pyenchant==3.2.2
Pygments==2.18.0
python-dateutil==2.8.2
requests==2.32.0
ruamel.yaml==0.17.21
ruamel.yaml.clib==0.2.7
six==1.16.0
snowballstemmer==2.2.0
soupsieve==2.4
Sphinx==7.3.7
sphinx-autodoc-typehints==1.23.0
sphinx-jinja2-compat==0.2.0
sphinx-prompt==1.5.0
sphinx-rtd-theme==2.0.0
sphinx_rtd_dark_mode==1.2.4
sphinx-sitemap==2.5.0
sphinx-tabs==3.4.1
sphinx-toolbox==3.4.0
sphinx_design==0.6.0
sphinxcontrib-applehelp==1.0.4
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.1
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==2.0.0
sphinxcontrib-spelling==8.0.0
tabulate==0.9.0
typing_extensions==4.5.0
urllib3==1.26.18
watchdog==3.0.0
webencodings==0.5.1
sphinx_reredirects==0.1.3
sphinx-notfound-page==1.0.0
# sphinx_last_updated_by_git==0.3.6
lextm commented 1 month ago

Did you try the steps in #899?

FrightRisk commented 1 month ago

I will try to understand 899, but I thought I just install the plugin in VSC. I seem to remember installing something 2 years ago in python that Esbonio needed done manually. When it just stopped working, I tried to look and see if a version of anything automatically updated without me knowing. I uninstalled the Python and Esbonio plugins and re-installed them. Now I see a box popup from reStructuredText saying "Please review Python installation on this machine before using this extension". I don't see that box if I run a venv. And this I see on a website which I don't understand: image

FrightRisk commented 1 month ago

I'm sorry, but I think this is beyond me. I inherited this system and am trying to understand this, but there does not seem to be one page with very clear steps to know how to install and debug this. This was all working perfectly a few days ago. I made no changes. The only thing I can think of is that one of the plugins that had the checkbox "auto update" may have updated and broken things. I am lost. I don't recall ever having to use github to create a repo for anything. I was hoping the log would at least give me a place to start.

Also, when I was running without the venv in VSC, and then ran my batch file to create the venv, VSC used to popup a box saying something like "new virtual environment recognized, do you want to use it?". That doesn't happen anymore.

alcarney commented 1 month ago

Preview windows says "no content found" and a popup in VSC says "ValueError: No Python Environment configured". I am using the same steps that have been working.

Windows 11, batch file creates a Venv and builds the website as usual. I go back into the run commands menu and deselect the python version and reselect it (my venv version) and restart the Esbonio server.

Sorry, chances are I broke your workflow here 😅

I'm assuming that VSCode updated the Esbonio extension in the background which would have included a breaking change. (See https://github.com/swyddfa/esbonio/pull/881/commits/82c548e0b17407589830db57d1b940619634ef13).

Hopefully, all you need to do to get things working again is to set the esbonio.sphinx.pythonCommand option to something like

{
  "esbonio.sphinx.pythonCommand": ["C:\\Users\\Fred\\Documents\\PlatformIO\\Projects\\dcc-ex.github.io\\venv\\Scripts\\python.exe"]
}

or wherever the batch file creates your virtual environment.

Don't worry about the esbonio.server.pythonPath option, it shouldn't be necessary (in fact I'm starting to think it should be removed entirely)

FrightRisk commented 1 month ago

Can I do this from the gear settings on the Esbonio plugin? It seems to edit the VSC settings.json file when changes are made there. I tried changing the path, but it didn't work. I went back to the previous version and that fixed it. I agree with you that is must be the path if that is the only breaking change. When I look at what the "choose interpreter" says in the VSC "run commands" menu, it shows "Python 3.10.11 ('venv':venv) .\venv\Scripts\python.ext". And when I entered the path into your config screen, I could see that it entered a line like you showed above and the path looked correct. If there is something else you want me to try, I'm happy to do it.

alcarney commented 1 month ago

Can I do this from the gear settings on the Esbonio plugin?

Yes either using the UI or editing the file itself should be fine.

I tried changing the path, but it didn't work

When you say it didn't work, are you still seeing the ValueError: No Python Environment configured message? If so it sounds like the settings.json file is not being applied :thinking: Where in relation to your project is the settings.json file?

If the config is being passed through correctly, I would expect you be able to see something like this

[esbonio.Configuration] Workspace 'file:///c%3A/Users/Fred/Documents/PlatformIO/Projects/dcc-ex.github.io' configuration: {
  "server": {
    ...
  },
  "sphinx": {
    "pythonCommand": [
      "C:\\Users\\Fred\\Documents\\PlatformIO\\Projects\\dcc-ex.github.io\\venv\\Scripts\\python.exe"
    ],
  },
  ...
}

in the log output.