How to work the easiest way with .NET references and additional python libraries

Hello guys,

Could you tell me how it is the easiest way to import further packages on python or ,NET side.
We have a) python packages b) .NET references which are being used in the python script.
Are there best practices and shorter ways to import .NET references/Python packages?

So as I noticed the python standard library has to be added by _scriptRun.ScriptSource.ModulesSearchPaths.Add(). But is there any way to import them directly over the python script? (like scientific python libraries)

The goal is to write a script which is running some tasks with the methods that are being imported through the .NET references and giving back a result to the main application where it is being embedded (same environment).
So we prefer to take the shortest and uncomplicated way to run new python tasks.
Currently we are still researching if IronPython and the Scripter are meeting our requirements to run
new scripts with much more different tasks smoothly.

I would really appreciate if you could give us some useful examples and as much information as you can.

Thank you in advance.

Hello,

It is possible to import Python modules using ModulesSearchPaths, as you mentioned. You need to get the files you need the module Python files from somewhere, put them in some directory, and specify that directory using ModulesSearchPaths. How to do that, will depend on the particular libraries you are want to use, and how much they are tied to CPython vs IronPython which the Scripter uses. For example, see this post for a discussion regarding using numpy on IronPython.

Regarding the .NET references, please refer to our CursomAssembly.IronPython demo, specifically the lines:

scriptRun.ScriptSource.ReferencesSearchPaths.Add(Path.GetDirectoryName(GetType().Assembly.Location));
scriptRun.ScriptSource.References.Add("ExternalAssembly.dll");
scriptRun.ScriptSource.Imports.Add("ExternalAssembly");

Thanks you very much! I will take a look at these topics.