IronLanguages / ironpython2

Implementation of the Python programming language for .NET Framework; built on top of the Dynamic Language Runtime (DLR).

Home Page:http://ironpython.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IronPython 2.7.10 not finding system dll modules

galahad25 opened this issue · comments

commented

Description

On a new computer installation when using a C# application launched with a command line to run Python script I would get both the time and errno modules not found errors.

Steps to Reproduce

  1. Install IronPython 2.7.10
  2. Run Python code that calls to import time or import os
  3. C# application running the Python returns module not found errors

Expected behavior: [What you expected to happen]
System dll modules to be found in the PYTHONPATH provided that worked for IronPython 2.7.9 that was installed on a different installation. I was able to uninstall IronPython 2.7.10 and then install 2.7.9 and it was able to find the modules without error.

Actual behavior: [What actually happened]
Module not found errors for time and errno modules.

Versions

IronPython 2.7.10

You can get this information from executing ipy -V.

I am unable to reproduce this issue. I installed IronPython 2.7.10 on a clean machine and have no issue with import os or import time:
image

commented

But you are importing them directly from the IronPython shell. I am trying to import them to a C# application using:
PythonEngine = Python.CreateEngine();

        SetPythonPath(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)); //exe directory
        SetPythonPath(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + @"\ScriptCommon");
        SetPythonPath(@"C:\Program Files\IronPython 2.7\Lib");

        PythonEngine.SetTrace(IronPythonTraceBack);

which with IronPython 2.7.9 worked. I am suspecting that an additional path that is already inherent to the IronPython shell will have to be added and I can not find any info on what that might be.

Ok, here's a C# version:

using IronPython.Hosting;

namespace ConsoleApp31
{
    class Program
    {
        static void Main(string[] args)
        {
            var engine = Python.CreateEngine();
            engine.SetSearchPaths(new[] { @"C:\Program Files\IronPython 2.7\Lib" });
            engine.Execute("import os; import time; import sys; print(sys.version)");
        }
    }
}

When run from the console (in a clean VM):

PS C:\Users\WDAGUtilityAccount\Documents\ConsoleApp31> .\ConsoleApp31.exe
2.7.10 (2.7.10.1000)
[.NETFramework,Version=v4.5 on .NET Framework 4.8.4180.0 (64-bit)]

commented

So any help or feedback from someone that can assist?

Is IronPython.Modules.dll getting loaded by your app? Not having this would cause os and time to fail to load.