Title: Getting an error when calling `load` more than once · Issue #2078 · pythonnet/pythonnet · GitHub
Open Graph Title: Getting an error when calling `load` more than once · Issue #2078 · pythonnet/pythonnet
X Title: Getting an error when calling `load` more than once · Issue #2078 · pythonnet/pythonnet
Description: Environment Pythonnet version: 3.0.1 Python version: 3.11.1 Operating System: Windows & Linux .NET Runtime: net6.0, net7.0 Details Describe what you were trying to get done. I have 2 libraries that are packaging some C# code with pythonn...
Open Graph Description: Environment Pythonnet version: 3.0.1 Python version: 3.11.1 Operating System: Windows & Linux .NET Runtime: net6.0, net7.0 Details Describe what you were trying to get done. I have 2 libraries that...
X Description: Environment Pythonnet version: 3.0.1 Python version: 3.11.1 Operating System: Windows & Linux .NET Runtime: net6.0, net7.0 Details Describe what you were trying to get done. I have 2 libraries ...
Opengraph URL: https://github.com/pythonnet/pythonnet/issues/2078
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Getting an error when calling `load` more than once","articleBody":"### Environment\r\n\r\n- Pythonnet version: 3.0.1\r\n- Python version: 3.11.1\r\n- Operating System: Windows \u0026 Linux\r\n- .NET Runtime: net6.0, net7.0\r\n\r\n### Details\r\n\r\n- Describe what you were trying to get done.\r\n\r\nI have 2 libraries that are packaging some C# code with pythonnet as a dependency so that they can be used from Python without issues. In both libraries I call ``load(\"coreclr\")`` in the ``__init__.py``. When a user try to load both libraries at the same time pythonnet throw an exception. It wasn't happening with pythonnet version 2 so I suspect that this is a bug of pythonnet version 3.\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```python\r\nfrom pythonnet import load\r\n\r\nload(\"coreclr\")\r\nload(\"coreclr\")\r\n```\r\n\r\n- If there was a crash, please include the traceback here.\r\n\r\n```python\r\nFailed to initialize pythonnet: System.InvalidOperationException: This property must be set before runtime is initialized\r\n at Python.Runtime.Runtime.set_PythonDLL(String value) in /tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Runtime.cs:line 27\r\n at Python.Runtime.Loader.Initialize(IntPtr data, Int32 size) in /tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Loader.cs:line 23\r\n at Python.Runtime.Runtime.set_PythonDLL(String value) in /tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Runtime.cs:line 27\r\n at Python.Runtime.Loader.Initialize(IntPtr data, Int32 size) in /tmp/build-via-sdist-dq4gmg3h/pythonnet-3.0.1/src/runtime/Loader.cs:line 23Traceback (most recent call last):\r\n File \"/home/gitlab-runner/test_pythonnet/test.py\", line 4, in \u003cmodule\u003e\r\n load(\"coreclr\")\r\n File \"/home/gitlab-runner/test_pythonnet/.venv/lib/python3.11/site-packages/pythonnet/__init__.py\", line 144, in load\r\n raise RuntimeError(\"Failed to initialize Python.Runtime.dll\")\r\nRuntimeError: Failed to initialize Python.Runtime.dll\r\n```\r\n\r\n\r\n","author":{"url":"https://github.com/bendhayer","@type":"Person","name":"bendhayer"},"datePublished":"2023-01-17T15:10:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2078/pythonnet/issues/2078"}
| 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:86fde516-1a06-36e1-a0ef-e8a35db4d62e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B900:81F30:1F72702:2A890A8:697083A9 |
| html-safe-nonce | 4d778c5b182ea795991f714db0fcbc969a8e49ca61f8be17d7b0332bbc41cd8c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTAwOjgxRjMwOjFGNzI3MDI6MkE4OTBBODo2OTcwODNBOSIsInZpc2l0b3JfaWQiOiIyNTMxMzQwODMyODE2MDA2MDU3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 127ffa6327fdfd80cd02dfa5df192cb37f80b330a4ebb0202a0591b2aae57999 |
| hovercard-subject-tag | issue:1536549352 |
| 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/2078/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8f93b54194c259c29088925175e53d30dbd9f2975fb92bc13f409327fe7245fe/pythonnet/pythonnet/issues/2078 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8f93b54194c259c29088925175e53d30dbd9f2975fb92bc13f409327fe7245fe/pythonnet/pythonnet/issues/2078 |
| og:image:alt | Environment Pythonnet version: 3.0.1 Python version: 3.11.1 Operating System: Windows & Linux .NET Runtime: net6.0, net7.0 Details Describe what you were trying to get done. I have 2 libraries that... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bendhayer |
| 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