Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS Code freezes and crashes when the Python extension activates on Windows #14236

Closed
andrepn opened this issue Oct 2, 2020 · 10 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@andrepn
Copy link

andrepn commented Oct 2, 2020

Similar issues: #6687 #9554 #3967 #5437 #9093

Environment data

  • VS Code version: 1.49.3
  • Extension version (available under the Extensions sidebar): v2020.9.112786
  • OS and version: Windows v2004
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.0 on WSL and 3.8.6 local
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): WSL
  • Relevant/affected Python packages and their versions: --
  • Relevant/affected Python-related VS Code extensions and their versions: ms-python Python extension
  • Value of the python.languageServer setting: Pylance

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

Python extension loads when .py file is opened or created and VS code continues to function

Actual behaviour

"Python extension loading" appears then eventually VS code freezes and crashes or disconnects me from my remote WSL environment

Steps to reproduce:

1.Open vs code
2.Open or create a .py file with the Python extension installed and enabled

Logs

When I follow these steps running vs code locally it freezes and crashes. When I run them on WSL: Ubuntu it eventually disconnects which forces me to close. I don't see anything in the output panel before it freezes. Occasionally a new file will open called "Getting Started -Python" right before VS code freezes.

I am relatively new [to vscode and development] so if there is some output you think exists it is likely that I just don't know how to get to it without being told.

Thank you for your help...

Andrew Noel

@andrepn andrepn added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Oct 2, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Oct 5, 2020
@kimadeline
Copy link

Hi @andrepn, thank you for reaching out.

I cross-checked this issue with what you initially reported on Discord, are all the following bullet points correct?

  • no crash or error if the python extension is not installed and you're not editing a python file
  • no crash or error if the python extension is not installed and you're editing a python file (you just have basic syntax highlighting)
  • if the python extension is installed and you open a python file locally, VS Code freezes and then crashes
  • if the python extension in installed in WSL and you open a python file in WSL, VS Code disconnects from the WSL environment
  • python extension 2020.9.112786 installed locally and in WSL

And you already tried:

  • uninstalling VS Code
  • uninstalling the python extension
  • using an older version of the python extension
  • deleting %USERPROFILE%/.vscode and AppData/Roaming/code

👉 Do you mind trying the following:

  • make VS Code + the python extension crash on local Windows (not WSL)

  • when reopening VS Code, open the command palette (Ctrl+Shift+P) and execute the Developer: Open Extension Logs Folder command:
    image

  • go to the parent folder containing log folders organized by timestamps, find the folder with the timestamp closest to the crash, and upload all the logs here in a zip file:
    image

(This is on macOS, but the folder structure should be similar on Windows)

Thanks!

@kimadeline kimadeline added the info-needed Issue requires more information from poster label Oct 5, 2020
@kimadeline kimadeline changed the title Python extension freezes and crashes my VS code of I open or create a .py file VS Code freezes and crashes when the Python extension activates on Windows Oct 5, 2020
@andrepn
Copy link
Author

andrepn commented Oct 6, 2020

Thank you for the reply. I'll try to post what you've asked for later today.

@andrepn
Copy link
Author

andrepn commented Oct 6, 2020

Hi @kimadeline ,

First, the following are correct:

no crash or error if the python extension is not installed and you're not editing a python file - correct
no crash or error if the python extension is not installed and you're editing a python file (you just have basic syntax highlighting) - correct
if the python extension is installed and you open a python file locally, VS Code freezes and then crashes - correct
if the python extension in installed in WSL and you open a python file in WSL, VS Code disconnects from the WSL environment - correct
python extension 2020.9.112786 installed locally and in WSL - correct but I've tried it with it only installed on WSL or only installed locally as well

I have tried all of the following:

uninstalling VS Code
uninstalling the python extension
using an older version of the python extension
deleting %USERPROFILE%/.vscode and AppData/Roaming/code

I've followed your recommended steps twice but unfortunately I don't have any .log files:
image

inside the timestamp file:
image

I tried crashing it twice and still this is all I see. Would it be helpful to see the contents of the exthost file? I'm wondering if my computer doesnt have enough RAM for so many virtual machines or if there is something out of wack with my Python path? Let me know what else you would like to see...

Thanks again for your help.

@kimadeline
Copy link

There's probably something else going on if VS Code is crashing when you're running it in Windows, or do you mean that it's a Windows VM?

In any case, yeah, do you mind sharing what's in exthost?

Thanks!

@andrepn
Copy link
Author

andrepn commented Oct 8, 2020

exthost.log

4-Python.log

Okay there is the exthost file and I was able to get a Python log file as well.

@kimadeline
Copy link

Thank you!

The python log that you updated ends with this line:

Error 2020-10-08 10:19:25: Detection of Python Interpreter for Command python3 and args failed as file does not exist

However that shouldn't be happening, since you have Python 3.8.6 installed locally.

Does the Python REPL show up when you type python3 in your terminal? What happens if you run the following command in your terminal?

python3 "c:\Users\Andrew Noel\.vscode\extensions\ms-python.python-2020.9.114305\pythonFiles\pyvsc-run-isolated.py" -c "import sys;print(sys.executable)"

Side note: We are currently refactoring our interpreter discovery module (#12020), and as a result we should handle these errors more gracefully and not cause crashes.

@andrepn
Copy link
Author

andrepn commented Oct 8, 2020

Okay it seems like we've found the problem. Here's more information than you asked for:

When I type "python":

Powershell: Python 3.8.6 REPL
Command-line: Python 3.8.6 REPL
WSL: Python 3.8.0 REPL

When I type "python3":

Powershell: nothing
Command-line: nothing
WSL: Python 3.8.0 REPL

Running the command from your comment:

Powershell: nothing
Command-line: nothing
WSL: [of course an error]

Do you know what steps I should take to fix this?

@kimadeline
Copy link

Hmmmm this might be a red herring though, because even though we log the failure as an error, we continue on with interpreter discovery, and ignore the interpreter calls that failed. For example, this is how it looks on my machine:

> pyenv root
> python3.7 ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3.6 ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3 ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python2 ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python ~/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
Error 2020-10-08 13:00:03: Detection of Python Interpreter for Command python3.7 and args  failed as file  does not exist
Error 2020-10-08 13:00:03: Detection of Python Interpreter for Command python2 and args  failed as file  does not exist
Error 2020-10-08 13:00:03: Detection of Python Interpreter for Command python3.6 and args  failed as file  does not exist
Error 2020-10-08 13:00:03: Failed to get interpreter information for '/Users/kimiguel/.pyenv/shims/python2' [Error: Command failed: "/Users/kimiguel/.pyenv/shims/python2" "/Users/kimiguel/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/pyvsc-run-isolated.py" "/Users/kimiguel/.vscode/extensions/ms-python.python-2020.9.114305/pythonFiles/interpreterInfo.py"

For now, let's take a look at what is going on in your local install of the extension, and once that's done we can figure out what is going on in WSL. Can you try the following to get more detailed logs:

  • disable the Pylance extension (just to remove one variable from the equation)
  • set the python.logging.level user setting to info:
    image
  • download the ms-python-insiders-vsix artifact from https://github.com/kimadeline/vscode-python/actions/runs/296335876 and extract its content (which should be an ms-python-insiders.vsix file)
  • in VS Code run the command Extensions: Install From VSIX in the command palette, select that vsix, and reload the window once it's installed (you should get a notification in the bottom right corner)
  • try to reproduce the crash (again, sorry about that), and upload the python log here

I also forgot to ask earlier, where does your local 3.8.0 Python install come from (python.org installer, Microsoft Store, Anaconda, etc)?

Thank you!

@andrepn
Copy link
Author

andrepn commented Oct 12, 2020

Sorry for the delay, I'll try to get this done later today thank you.

@brettcannon
Copy link
Member

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on then we will be happy to re-open this issue to pick up where we left off.

@ghost ghost removed the triage label Nov 17, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants