Skip to content
\n\"Image\"\n

I tried to step into the code, but quickly ran into unmanaged code before finding where the exception was thrown.

\n
Fatal error. 0xC0000005\n   at Python.Runtime.Runtime.PyImport_ImportModule(System.String)\n   at Python.Runtime.PyModule.Import(System.String)\n   at Python.Runtime.Py.Import(System.String)\n   at YtDlpTest.TestYtDlp..ctor()\n   at DynamicClass.lambda_method172(System.Runtime.CompilerServices.Closure)\n   at System.Management.Automation.CommandProcessor.Init(System.Management.Automation.CmdletInfo)\n   at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(System.Management.Automation.CommandInfo, System.Management.Automation.CommandOrigin, System.Nullable`1<Boolean>, System.Management.Automation.SessionStateInternal)\n   at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(System.String, System.Management.Automation.CommandOrigin, System.Nullable`1<Boolean>)\n   at System.Management.Automation.ExecutionContext.CreateCommand(System.String, Boolean)\n   at System.Management.Automation.PipelineOps.AddCommand(System.Management.Automation.Internal.PipelineProcessor, System.Management.Automation.CommandParameterInternal[], System.Management.Automation.Language.CommandBaseAst, System.Management.Automation.CommandRedirection[], System.Management.Automation.ExecutionContext)\n   at System.Management.Automation.PipelineOps.InvokePipeline(System.Object, Boolean, System.Management.Automation.CommandParameterInternal[][], System.Management.Automation.Language.CommandBaseAst[], System.Management.Automation.CommandRedirection[][], System.Management.Automation.Language.FunctionContext)\n   at System.Management.Automation.Interpreter.ActionCallInstruction`6[[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Boolean, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Run(System.Management.Automation.Interpreter.InterpretedFrame)\n   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)\n   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)\n   at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)\n   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon)\n   at System.Management.Automation.DlrScriptCommandProcessor.RunClause(System.Action`1<System.Management.Automation.Language.FunctionContext>, System.Object, System.Object)\n   at System.Management.Automation.DlrScriptCommandProcessor.Complete()\n   at System.Management.Automation.CommandProcessorBase.DoComplete()\n   at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(System.Management.Automation.CommandProcessorBase)\n   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object)\n   at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()\n   at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()\n   at System.Management.Automation.Runspaces.PipelineThread.WorkerProc()\n   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)\n
","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"

Now I find out I have to use gil for even the import. The source I was following didn't mention that.

","upvoteCount":1,"url":"https://github.com/pythonnet/pythonnet/discussions/2675#discussioncomment-15399546"}}}
Discussion options

You must be logged in to vote

Now I find out I have to use gil for even the import. The source I was following didn't mention that.

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@WillPittenger
Comment options

@WillPittenger
Comment options

@WillPittenger
Comment options

@WillPittenger
Comment options

Comment options

You must be logged in to vote
2 replies
@filmor
Comment options

@WillPittenger
Comment options

Answer selected by WillPittenger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2674 on December 28, 2025 11:14.