IronLanguages / ironpython3

Implementation of Python 3.x for .NET Framework that is built on top of the Dynamic Language Runtime.
Apache License 2.0
2.48k stars 287 forks source link

IronPython.Runtime.Exceptions.ImportException: 'No module named 'xml.etree.ElementTree'' #1787

Open ssalmans428 opened 6 months ago

ssalmans428 commented 6 months ago

Hi,

I am trying to run python script from C# (.net Framework 4.7 Class Library Project) . I am using Visual studio 2022. I have added IronPython 3.4.1 as reference to my project, IronPython.StdLib 3.4.1 also added.

When there are no import statements inside the script it is running fine, when there is an import statement in my script file its throwing an "No Module Found error" even though the module is found under the lib folder.

This error is not specific to a module its giving me error for all the basic modules like Math module also.

I added the Searchpaths as well mapping to the lib folder, but still getting the error. Can you tell me what needs to be changed here?

Capture6 Capture5 Capture4

Let me know if you require more details......

slozier commented 6 months ago

Why are there { and } in your libs path?

ssalmans428 commented 6 months ago

Why are there { and } in your libs path?

Hi I modified the syntax now also the error is coming related to Module _sre. I have not used this one in my Script. From where this is popping up?

Can you provide me the correct way to map the libs?

image

slozier commented 6 months ago

_sre is a built-in module and not part of the lib. It sounds like IronPython.Modules.dll is not getting copied to your output folder (same issue as https://github.com/IronLanguages/ironpython3/issues/1778).

ssalmans428 commented 6 months ago

_sre is a built-in module and not part of the lib. It sounds like IronPython.Modules.dll is not getting copied to your output folder (same issue as #1778).

Hi, I manually place the dll's in output folder but now i am getting the error related to Import requests. 1.Requests module is not available in ironpython? 2.I can see request.py is available under urllib folder are these same? 3.Any workaround for requests module in ip?

image image

slozier commented 6 months ago

The requests module is not part of the standard library. You'll have to find a compatible version (e.g. 2.21.0) and make it (and its dependencies) available in your search paths.