Re: Ironpython 2.7.9 ImportException: 'No Module Named errno' when importing another module in .NET application

Stéphane Lozier
 

I'm not sure why removing the site-packages from the search paths would have an effect on loading IronPython.Modules since it occurs in within Python.CreateEngine(). You can check that it gets loaded by adding something like:

Debug.Assert(AppDomain.CurrentDomain.GetAssemblies().Select(x => x.GetName().Name).Contains("IronPython.Modules"));

right after you create the engine.

Are you sure "import jinja2" was still failing with the ImportError and not something else? Note that jinja2 will fail with a SyntaxError if you try to import it from IronPython. You'll have to tweak lexer.py to get it working.

On Fri, Nov 30, 2018 at 12:40 PM micoo via Groups.Io <micoo=microsoft.com@groups.io> wrote:

Thanks for the reply. I did a little more exploring this morning and I think Stéphane is probably right, or at the very least on the right path.

If I remove the following line:

searchPaths.Add($@"{pythonRootPath}\Lib\site-packages\");

I can run the following script with no issues where previously I was unable to import either of these packages without an import error:
engine.Execute(@"
    import os, json
    print os.getcwd()
    print json.dumps({'x': 1, 'y': { 'hello': 'world' }, 'z': True}, indent=4)");

So if I can't add the path my package is in to sys path...how can I import it? I've tried fully qualifying the path as "C:\python27\Lib\site-packages\jinja2" and that doesn't work.

Join users@ironpython.groups.io to automatically receive all group messages.