IronPython invocation from C# (with SciPy) fails with ImportException: “No module named mtrand”

后端 未结 2 1470
我寻月下人不归
我寻月下人不归 2021-02-05 15:10

I have a python library I am trying to use via IronPython (v2.7 RC1 [2.7.0.30]) invocation from C# application. The library uses NumPy and SciPy quite extensively, which

相关标签:
2条回答
  • 2021-02-05 15:19

    Not the best soultion, but its works for me:

    import sys
    sys.path.append(r'c:\Program Files (x86)\IronPython 2.7')
    sys.path.append(r'c:\Program Files (x86)\IronPython 2.7\DLLs')
    sys.path.append(r'c:\Program Files (x86)\IronPython 2.7\Lib')
    sys.path.append(r'c:\Program Files (x86)\IronPython 2.7\Lib\site-packages')
    
    import clr
    clr.AddReference('mtrand.dll')
    
    import numpy
    import scipy
    
    print numpy.__version__
    print scipy.__version__
    

    I hope it helps.

    0 讨论(0)
  • 2021-02-05 15:42

    I found that, in my ActivePython V2.7.0.2, this works:

    sys.path.append(r'C:\\Examples')
    import examples
    

    (assuming examples.py is in C:\Examples). This doesn't (without the r):

    sys.path.append('C:\\Examples')
    import examples
    

    Because I get this:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named examples
    

    Conclusion: mind the r''!

    0 讨论(0)
提交回复
热议问题