Question
When I ssh to the server for debugging, I found that it didn't work because it hadn't worked for a long time. So I just ran the code in the terminal and there was no problem. It should be a configuration problem with vscode itself.
Solution
Because the Python plug-in of vscode is updated to the latest release version by default, it is incompatible (the plug-in is automatically updated during reload, and the interpreter version lags accordingly), so it is rolled back to an available historical version.
When installing install another version
, roll back to an available version.
Then
Turn off automatic updates in vscode How to turn off automatic updates