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.


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:


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

I am using alternet 8 version.

However, if I add these later during runtime (for example with button add additional reference), I do not get in autocomplete in TextEditor. (Autocomplete is not refreshed).

For C# there is Editor.RegisterAssembly(dllPath); then Editor.Lexer.Update(); but for python I cannot find to refreshe autocomplete.

if I do References.Add(file); before first time Editor is visible everything works ok. But if do it after visibility, autocomplete list does not refreshes…

Hi Audrius,

Most likely it happens as we cache .NET types per code environment, and this cache is not getting refreshed when you add Imports dynamically.

To verify this assumption, could you set a new code environment to the Parser upon changing Scripter’s import list like this:

parser.CodeEnvironment = new Alternet.Common.Python.CodeEnvironment(scriptRun1.CodeEnvironment.GlobalItems, scriptRun1.CodeEnvironment.ModulesSearchPaths, scriptRun1.CodeEnvironment.Imports, scriptRun1.CodeEnvironment.References, scriptRun1.CodeEnvironment.Technology);