Title: PythonEngine fails to initialize in VSIX extension · Issue #2404 · pythonnet/pythonnet · GitHub
Open Graph Title: PythonEngine fails to initialize in VSIX extension · Issue #2404 · pythonnet/pythonnet
X Title: PythonEngine fails to initialize in VSIX extension · Issue #2404 · pythonnet/pythonnet
Description: Environment Pythonnet version: 3.0.3, 3.1.0 Python version: 3.09 Operating System: Win11 .NET Runtime: 4.8 Details Describe what you were trying to get done. I am trying to use pythonnet package in a VSIX Visual Studio extension. The Exp...
Open Graph Description: Environment Pythonnet version: 3.0.3, 3.1.0 Python version: 3.09 Operating System: Win11 .NET Runtime: 4.8 Details Describe what you were trying to get done. I am trying to use pythonnet package in...
X Description: Environment Pythonnet version: 3.0.3, 3.1.0 Python version: 3.09 Operating System: Win11 .NET Runtime: 4.8 Details Describe what you were trying to get done. I am trying to use pythonnet package in...
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/2404
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PythonEngine fails to initialize in VSIX extension","articleBody":"### Environment\r\n\r\n- Pythonnet version: 3.0.3, 3.1.0\r\n- Python version: 3.09\r\n- Operating System: Win11\r\n- .NET Runtime: 4.8\r\n\r\n### Details\r\n\r\n- Describe what you were trying to get done.\r\n\r\nI am trying to use pythonnet package in a VSIX Visual Studio extension.\r\nThe Experimental VS Instance initializes pythonnet fine, however deploying an extension causes this crash.\r\nI suspect there may be some threading issues, but am not sure what to look for.\r\n\r\n- What commands did you run to trigger this issue? If you can provide a\r\n [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve)\r\n this will help us understand the issue.\r\n\r\n```\r\ntry\r\n{\r\n Runtime.PythonDLL = pythonFile.FullName;\r\n PythonEngine.PythonHome = pythonFile.DirectoryName!;\r\n OutputWindowHelper.LogInfo(\"PythonEngine\", \"Initializing Python engine.\");\r\n PythonEngine.Initialize(); // crash here\r\n PythonEngine.BeginAllowThreads();\r\n}\r\ncatch (Exception ex)\r\n{\r\n OutputWindowHelper.LogError(ex);\r\n}\r\n```\r\n\r\n- If there was a crash, please include the traceback here.\r\n```\r\n[INFO] - PythonEngine: Initializing Python engine.\r\n[ERROR]: Object reference not set to an instance of an object.\r\n[TRACE]: at Python.Runtime.ClassManager.GetClassInfo(Type type, ClassBase impl)\r\n at Python.Runtime.ClassManager.InitClassBase(Type type, ClassBase impl, ReflectedClrType pyType)\r\n at Python.Runtime.ReflectedClrType.GetOrCreate(Type type)\r\n at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess)\r\n at Python.Runtime.ModuleObject.LoadNames()\r\n at Python.Runtime.ImportHook.UpdateCLRModuleDict()\r\n at Python.Runtime.PythonEngine.Initialize(IEnumerable`1 args, Boolean setSysArgv, Boolean initSigs)\r\n at Python.Runtime.PythonEngine.Initialize()\r\n at cpGames.VSA.ToolAPI.\u003cInitializePythonEngineAsync\u003ed__2.MoveNext() in ToolAPI.cs:line 69 // PythonEngine.Initialize(); call\r\n```\r\n","author":{"url":"https://github.com/cpgames","@type":"Person","name":"cpgames"},"datePublished":"2024-06-22T22:22:40.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/2404/pythonnet/issues/2404"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9920281f-7031-91cc-f4c3-defc80694a4c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CAC2:6CA27:1EE14E2:29BE0C2:69707E86 |
| html-safe-nonce | 8b7a4b10230910d848b30a7ecb3ebd34c602a92210f301a853b79bfa344c96a8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQUMyOjZDQTI3OjFFRTE0RTI6MjlCRTBDMjo2OTcwN0U4NiIsInZpc2l0b3JfaWQiOiIxMTc5ODUwODM5NjUyNTk3MzgyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b89e30c081746f644f5a01565247a4e3225186ca213e75a28173912c424f7ec2 |
| hovercard-subject-tag | issue:2368048044 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pythonnet/pythonnet/2404/issue_layout |
| twitter:image | https://opengraph.githubassets.com/66ac9740a259c581f0a5f972cf0532315eb25d111a6074044252180accc82e42/pythonnet/pythonnet/issues/2404 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/66ac9740a259c581f0a5f972cf0532315eb25d111a6074044252180accc82e42/pythonnet/pythonnet/issues/2404 |
| og:image:alt | Environment Pythonnet version: 3.0.3, 3.1.0 Python version: 3.09 Operating System: Win11 .NET Runtime: 4.8 Details Describe what you were trying to get done. I am trying to use pythonnet package in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cpgames |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9920a62ba22d06470388e2904804fb7e5ec51c9e35f81784e9191394c74b2bd2 |
| turbo-cache-control | no-preview |
| go-import | github.com/pythonnet/pythonnet git https://github.com/pythonnet/pythonnet.git |
| octolytics-dimension-user_id | 6050430 |
| octolytics-dimension-user_login | pythonnet |
| octolytics-dimension-repository_id | 14748123 |
| octolytics-dimension-repository_nwo | pythonnet/pythonnet |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14748123 |
| octolytics-dimension-repository_network_root_nwo | pythonnet/pythonnet |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7d6181066430cc06553c8396ca201e194ae33cb9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width