microsoft / PTVS

Python Tools for Visual Studio
https://aka.ms/PTVS
Apache License 2.0
2.53k stars 676 forks source link

Visual Studio 2019 crashes when I open the Python Environments window #6309

Closed vsfeedback closed 3 years ago

vsfeedback commented 3 years ago

This issue has been moved from a ticket on Developer Community.


Hi, I just installed Visual Studio 2019 and tried out different Python environments. Now when I am trying to open the Python Environments window it shows up for some seconds and than the programm chrashes and restarts...


Original Comments

Dada Huo [MSFT] on 11/5/2020, 07:26 PM:

Thank you for taking the time to log this issue!

In order for us to investigate further, please provide more information by recording your repro steps via the Visual Studio Feedback Tool (Help -> Send Feedback -> Report A Problem). The feedback tool will ensure that we collect the needed information for you without worrying about what to provide (recording, dump file or ETL trace). Since this issue is now marked as Need More Info, that workflow is enabled in the Feedback Tool – full instructions
In our guidelines , you can get tips on how to provide clear and simple reproducible steps.

Get performance issues fixed quicker, please see https://docs.microsoft.com/en-us/visualstudio/ide/how-to-increase-chances-of-performance-issue-being-fixed?view=vs-2019.

We look forward to hearing from you!

1976016983 on 11/8/2020, 06:23 PM:

I have the same problem. Environments were created with Anaconda. I can switch environments in VS and open the “Add Environment” dialog, but clicking “Manage packages for this environment” or “Open the Python Environments” results in a crash.

Feedback Bot on 11/12/2020, 00:10 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

huguesv commented 3 years ago
Data: Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.InvalidOperationException
   at Microsoft.PythonTools.Parsing.PythonLanguageVersionExtensions.ToLanguageVersion(System.Version)
   at Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreterFactory..ctor(Microsoft.PythonTools.Interpreter.InterpreterConfiguration, Microsoft.PythonTools.Interpreter.InterpreterFactoryCreationOptions, Boolean)

Exception Info: System.ArgumentException
   at Microsoft.PythonTools.Interpreter.Ast.AstPythonInterpreterFactory..ctor(Microsoft.PythonTools.Interpreter.InterpreterConfiguration, Microsoft.PythonTools.Interpreter.InterpreterFactoryCreationOptions, Boolean)
   at Microsoft.PythonTools.Interpreter.InterpreterFactoryCreator.CreateInterpreterFactory(Microsoft.PythonTools.Interpreter.InterpreterConfiguration, Microsoft.PythonTools.Interpreter.InterpreterFactoryCreationOptions)
   at Microsoft.PythonTools.Interpreter.CondaEnvironmentFactoryProvider.CreateFactory(Microsoft.PythonTools.Interpreter.PythonInterpreterInformation)
   at Microsoft.PythonTools.Interpreter.PythonInterpreterInformation.GetOrCreateFactory(System.Func`2<Microsoft.PythonTools.Interpreter.PythonInterpreterInformation,Microsoft.PythonTools.Interpreter.IPythonInterpreterFactory>)
   at Microsoft.PythonTools.Interpreter.CondaEnvironmentFactoryProvider.GetInterpreterFactory(System.String)
   at Microsoft.PythonTools.Interpreter.InterpreterRegistryService.FindInterpreter(System.String)
   at Microsoft.PythonTools.EnvironmentsList.ToolWindow+<>c__DisplayClass29_1.<UpdateEnvironments>b__3(Microsoft.PythonTools.Interpreter.InterpreterConfiguration)
   at Microsoft.PythonTools.Infrastructure.ObservableCollectionExtensions.Merge[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.ObjectModel.ObservableCollection`1<System.__Canon>, System.Collections.Generic.IEnumerable`1<System.__Canon>, System.Func`2<System.__Canon,System.__Canon>, System.Func`2<System.__Canon,System.__Canon>, System.Func`2<System.__Canon,System.__Canon>, System.Collections.Generic.IEqualityComparer`1<System.__Canon>, System.Collections.Generic.IComparer`1<System.__Canon>)
   at Microsoft.PythonTools.EnvironmentsList.ToolWindow.UpdateEnvironments(System.String)
   at Microsoft.PythonTools.EnvironmentsList.ToolWindow.FirstUpdateEnvironments()
   at System.Windows.Threading.DispatcherOperation.InvokeDelegateCore()
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at Microsoft.PythonTools.Infrastructure.TaskExtensions.ReThrowTaskException(System.Object)
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory+SingleExecuteProtector.TryExecute()
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory+SingleExecuteProtector+<>c.<.cctor>b__20_0(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)

This is on VS 2019 16.7. It's due to a detected Python 3.9 environment that we can't parse into the PythonLanguageVersion enum since 3.9 was not a member of that enum back then.

It has been added in 16.8 so this particular environment/scenario should no longer lead to a crash.

We should still fix the calling code to not crash on InvalidOperationException since that will still happen on future unknown versions of Python.