Title: Unable to from/import a .NET 8 library · pythonnet/pythonnet · Discussion #2421 · GitHub
Open Graph Title: Unable to from/import a .NET 8 library · pythonnet/pythonnet · Discussion #2421
X Title: Unable to from/import a .NET 8 library · pythonnet/pythonnet · Discussion #2421
Description: Unable to from/import a .NET 8 library
Open Graph Description: I'm trying to pull my .NET library into Python and getting a failure on the from/import statement. Repro Steps: Git clone this repo (.NET 8 class library) Compile the Neighborly library (defaults t...
X Description: I'm trying to pull my .NET library into Python and getting a failure on the from/import statement. Repro Steps: Git clone this repo (.NET 8 class library) Compile the Neighborly library (defaul...
Opengraph URL: https://github.com/pythonnet/pythonnet/discussions/2421
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Unable to from/import a .NET 8 library","text":"I'm trying to pull my .NET library into Python and getting a failure on the from/import statement.
\nRepro Steps:
\n\n- Git clone this repo (.NET 8 class library)
\n- Compile the Neighborly library (defaults to .NET 8 - Any CPU)
\n- Write a Python script with Pythonnet installed via pip:
\n
\nclr.AddReference(r\"C:\\MyPathTo\\Neighborly.dll\")\nfrom Neighborly import *\n
\nError:
\nTraceback (most recent call last):\n File \"c:\\Code\\SampleLib\\Test.py\", line 18, in <module>\n from Neighborly import *\nModuleNotFoundError: No module named 'Neighborly'\n
\nLooking at the IL metadata, I can confirm that Neighborly is the assembly name and also the namespace.
\n
\nI created a sample class with an Add function that compiled and was successfully imported into Python.
\nI also added all of the same Nuget dependencies and recompiled them. It continues to call the Add function.
\nThis rules out a dependency load failure.
\nI'm running on Windows 11 with Python 3.10.11.
\nAny ideas? 🙏
","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"As documented, by default we load a .NET Framework runtime at startup. The simplest option is to run import pythonnet; pythonnet.load(\"coreclr\") before importing clr.
","upvoteCount":2,"url":"https://github.com/pythonnet/pythonnet/discussions/2421#discussioncomment-10132002"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:da17586e-32e6-3e53-ec58-498517481fc2 |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | C8E2:17BD0F:314DBA8:31FF952:697031DA |
| html-safe-nonce | a9ab985fa43b437abc693feeb05e5c079f3e19d539f8406eb53b155ad143472c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOEUyOjE3QkQwRjozMTREQkE4OjMxRkY5NTI6Njk3MDMxREEiLCJ2aXNpdG9yX2lkIjoiMTAxODUwOTY1ODczODkzMDEzOCIsInJlZ2lvbl9lZGdlIjoic2VhIiwicmVnaW9uX3JlbmRlciI6InNlYSJ9 |
| visitor-hmac | 10fe7055bf93a36029f0748d5712b3e52b216e750bab92113cab9a9d83b95dee |
| hovercard-subject-tag | discussion:6969977 |
| github-keyboard-shortcuts | repository,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/Voltron::DiscussionsFragmentsController/show/pythonnet/pythonnet/2421/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/1b750e5f5310c394f78613913c5c58e3460a6e1ec2fe3dae1fa979f8f2e63c3e/pythonnet/pythonnet/discussions/2421 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1b750e5f5310c394f78613913c5c58e3460a6e1ec2fe3dae1fa979f8f2e63c3e/pythonnet/pythonnet/discussions/2421 |
| og:image:alt | I'm trying to pull my .NET library into Python and getting a failure on the from/import statement. Repro Steps: Git clone this repo (.NET 8 class library) Compile the Neighborly library (defaults t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| 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 | f643964067a552f02067066d6a910b2f90a5721f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width