SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Sharpdevelop and numpy/scipy for ironpython

Last post 10-22-2014 8:57 PM by Stocklone. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 07-26-2012 11:57 PM

    Sharpdevelop and numpy/scipy for ironpython

    Hi Everyone - I'm very new to SharpDevelop, but so far I'm very impressed - big hat tip to the developers and the community.

    I'm running into some problems when I attempt to use the Enthought .NET versions of numpy and scipy in my code.  I'm using SharDevelop v4.2.1, which runs IronPython 2.7.3 on .NET 4.0 (32 bit).  I've also separately installed an identical version of ironpython on my machine, and have followed the instructions on Enthought's site ( http://www.enthought.com/repo/.iron/ ), and I now have a working version of numpy and scipy through my separate install of ironpython.  Of course, what I ultimately need is to be able to include numpy and scipy in my code in SharpDevelop; however, I'm running into IOError's when I try to do this.  The code example that I execute line by line in the python console inside SharpDevelop, and the resulting error are shown below.

    It seems like the .NET versions would work, given that I've used the same version of IronPython as is used by SharpDevelop.  Has anyone had success in using numpy and scipy in SharpDevelop?

    Thanks a bunch,

    Mike

    print "Hello, World!"
    import sys
    sys.path.append("C:\Program Files (x86)\IronPython 2.7\Lib") # location of my stand-alone ironpython install
    sys.path.append("C:\\Program Files (x86)\\IronPython 2.7\\lib\\site-packages")
    import os
    print os.getcwd() # this line correctly prints "C:\Program Files (x86)\SharpDevelop\4.2\bin"
    import numpy

    at this point I get an explosion of errors:

    Traceback (most recent call last):
      File 
    "<stdin>", line 1in <module>
      File 
    "C:\Program Files (x86)\IronPython 2.7\lib\site-packages umpy\__init__.py", line 155in <module>
      File 
    "C:\Program Files (x86)\IronPython 2.7\lib\site-packages umpy\core\__init__.py", line 6in <module>
      File 
    "C:\Program Files (x86)\IronPython 2.7\lib\site-packages umpy\core\multiarray.py", line 6in <module>
    IOError: System.IO.IOException: Could 
    not add reference to assembly NumpyDotNet
       at IronPython.Runtime.ClrModule.
    AddReference(CodeContext context, String name)
       at IronPython.Runtime.ClrModule.
    AddReference(CodeContext context, Object reference)
       at IronPython.Runtime.ClrModule.
    AddReference(CodeContext context, Object[ references)
       at Microsoft.Scripting.Interpreter.ActionCallInstruction`
    2.Run(InterpretedFrame frame)
       at Microsoft.Scripting.Interpreter.Interpreter.
    Run(InterpretedFrame frame)
       at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
       at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
       at Microsoft.Scripting.Interpreter.FuncCallInstruction`
    6.Run(InterpretedFrame frame)
       at Microsoft.Scripting.Interpreter.Interpreter.
    Run(InterpretedFrame frame)
       at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
       at IronPython.Compiler.Ast.CallExpression.Invoke1Instruction.
    Run(InterpretedFrame frame)
       at Microsoft.Scripting.Interpreter.Interpreter.
    Run(InterpretedFrame frame)
       at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
       at IronPython.Compiler.RuntimeScriptCode.
    InvokeTarget(Scope scope)
       at IronPython.Compiler.RuntimeScriptCode.
    Run(Scope scope)
       at IronPython.Runtime.PythonContext.
    InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options)
       at IronPython.Runtime.PythonContext.
    CompileModule(String fileName, String moduleName, SourceUnit sourceCode, ModuleOptions options, ScriptCode& scriptCode)
       at IronPython.Runtime.Importer.
    LoadModuleFromSource(CodeContext context, String name, String path)
       at IronPython.Runtime.Importer.
    LoadFromDisk(CodeContext context, String name, String fullName, String str)
       at IronPython.Runtime.Importer.
    ImportFromPathHook(CodeContext context, String name, String fullName, List path, Func`5 defaultLoader)
       at IronPython.Runtime.Importer.
    ImportFromPath(CodeContext context, String name, String fullName, List path)
       at IronPython.Runtime.Importer.
    ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level)
       at IronPython.Modules.Builtin.
    __import__(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level)
       at IronPython.Runtime.Importer.
    ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level)
       at IronPython.Runtime.Operations.PythonOps.
    ImportTop(CodeContext context, String fullName, Int32 level)
       at Microsoft.Scripting.Interpreter.FuncCallInstruction`
    4.Run(InterpretedFrame frame)
       at Microsoft.Scripting.Interpreter.Interpreter.
    Run(InterpretedFrame frame)
       at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
       at IronPython.Compiler.RuntimeScriptCode.
    InvokeTarget(Scope scope)
       at IronPython.Compiler.RuntimeScriptCode.
    Run(Scope scope)
       at IronPython.Runtime.PythonContext.
    InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options)
       at IronPython.Runtime.PythonContext.
    CompileModule(String fileName, String moduleName, SourceUnit sourceCode, ModuleOptions options, ScriptCode& scriptCode)
       at IronPython.Runtime.Importer.
    LoadModuleFromSource(CodeContext context, String name, String path)
       at IronPython.Runtime.Importer.
    LoadPackageFromSource(CodeContext context, String name, String path)
       at IronPython.Runtime.Importer.
    LoadFromDisk(CodeContext context, String name, String fullName, String str)
       at IronPython.Runtime.Importer.
    ImportFromPathHook(CodeContext context, String name, String fullName, List path, Func`5 defaultLoader)
       at IronPython.Runtime.Importer.
    ImportFromPath(CodeContext context, String name, String fullName, List path)
       at IronPython.Runtime.Importer.
    ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level)
       at IronPython.Modules.Builtin.
    __import__(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level)
       at IronPython.Runtime.Importer.
    ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level)
       at IronPython.Runtime.Operations.PythonOps.
    ImportTop(CodeContext context, String fullName, Int32 level)
       at Microsoft.Scripting.Interpreter.FuncCallInstruction`
    4.Run(InterpretedFrame frame)
       at Microsoft.Scripting.Interpreter.Interpreter.
    Run(InterpretedFrame frame)
       at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
       at IronPython.Compiler.RuntimeScriptCode.
    InvokeTarget(Scope scope)
       at IronPython.Compiler.RuntimeScriptCode.
    Run(Scope scope)
       at IronPython.Runtime.PythonContext.
    InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options)
       at IronPython.Runtime.PythonContext.
    CompileModule(String fileName, String moduleName, SourceUnit sourceCode, ModuleOptions options, ScriptCode& scriptCode)
       at IronPython.Runtime.Importer.
    LoadModuleFromSource(CodeContext context, String name, String path)
       at IronPython.Runtime.Importer.
    LoadPackageFromSource(CodeContext context, String name, String path)
       at IronPython.Runtime.Importer.
    LoadFromDisk(CodeContext context, String name, String fullName, String str)
       at IronPython.Runtime.Importer.
    ImportFromPathHook(CodeContext context, String name, String fullName, List path, Func`5 defaultLoader)
       at IronPython.Runtime.Importer.
    ImportFromPath(CodeContext context, String name, String fullName, List path)
       at IronPython.Runtime.Importer.
    ImportTopAbsolute(CodeContext context, String name)
       at IronPython.Runtime.Importer.
    ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level)
       at IronPython.Modules.Builtin.
    __import__(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level)
       at IronPython.Runtime.Importer.
    ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level)
       at IronPython.Runtime.Operations.PythonOps.
    ImportTop(CodeContext context, String fullName, Int32 level)
       at Microsoft.Scripting.Interpreter.FuncCallInstruction`
    4.Run(InterpretedFrame frame)
       at Microsoft.Scripting.Interpreter.Interpreter.
    Run(InterpretedFrame frame)
       at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
       at IronPython.Compiler.PythonScriptCode.
    RunWorker(CodeContext ctx)
       at IronPython.Compiler.PythonScriptCode.
    Run(Scope scope)
       at IronPython.Hosting.PythonCommandLine.<>c__DisplayClass1.<RunOneInteraction>
    b__0()

  • 07-27-2012 11:22 PM In reply to

    Re: Sharpdevelop and numpy/scipy for ironpython

    I have not tried numpy or scipy.

    SharpDevelop 4.2 uses IronPython 2.7.2 not the latest version since I still have not upgraded it. However that is probably not the problem.

    The exception callstack suggests that it is failing to find the .NET assembly NumpyDotNet. Looking at the IronPython source code it is trying to do an Assembly.Load or Assembly.LoadWithPartialName.

    My guess is that NumpyDotNet.dll is in IronPython's DLLs folder. So copying that file from there into SharpDevelop's AddIns\BackendBindings\PythonBinding\DLLs folder may work. Or adding the reference directly in code before importing numpy might work.

  • 07-28-2012 4:38 AM In reply to

    Re: Sharpdevelop and numpy/scipy for ironpython

     Hi Matt - thanks for your response.  I've made a bit of progress in getting this to work using a different line of attack.  I found an older post on getting numpy to run on sharpdevelop 3.1 using ironclad ( https://groups.google.com/forum/?fromgroups#!topic/c-extensions-for-ironpython/hScaqbWFj3M ), and I've found that solution to work well for running the code via sharpdevelop's debugger.  In short, the author of that post directed sharpdevelop to start an external program (which is my external installation of ironpython) and to set the environment variable IRONPYTHONPATH so that the it can find the libraries and site packages.

    All this works great until I try to run the actual solution - that is to say, to double click on my HelloWorld.exe in either the debug or the build directories (I've tried both).  I think the issue is that sharpdevelop is using its own installation of ironpython for creating the actual solution, and so the output program can't run.  I've tried going into Tools > Options > Tools > Python and specifying my external installation of ironpython in the "command" line (plus, I've added the command line argument -X:Frames for scipy to run), but this doesn't help (with or w/o the -X:Frames bit).  The program fails to load in every case.

    Is there a way that I can specify which installation of ironpython to use for compilation?  And if so, to use a command line argument?

    By the way, I tried copying numpy' dll's into sharpdevelop's dll folder (and everything from Lib as well), but with no success - I get all sorts of dll errors there too.

    Thanks again,

    Mike

  • 07-28-2012 11:24 AM In reply to

    Re: Sharpdevelop and numpy/scipy for ironpython

    Tools-Options-Python has no effect on a compiled exe since you are running the exe and not ipy.exe.

    SharpDevelop will use the version of IronPython it ships with to do the compilation. I would try the IronPython compiler pyc.py that ships with IronPython 2.7.3 to see if that works.

  • 10-13-2013 9:14 PM In reply to

    • ric
    • Not Ranked
    • Joined on 10-05-2013
    • Posts 8

    Re: Sharpdevelop and numpy/scipy for ironpython

    Have you solved numpy's problem ?

  • 05-05-2014 9:55 PM In reply to

    • ph0x
    • Not Ranked
    • Joined on 05-05-2014
    • Posts 1

    Re: Sharpdevelop and numpy/scipy for ironpython

    I did the following to get numpy working:

    - Install Ironpython 2.7.4

    - Install scipy/numpy to Ironpython as mentioned here: https://www.enthought.com/repo/.iron/

    - copy all missing DLLs from the IronPython Installdir (e.g. C:\Program Files (x86)\IronPython 2.7\DLLs\) to the following DLL-Dir in the Installation Path of SharpDevelop (C:\Program Files (x86)\SharpDevelop\4.4\AddIns\BackendBindings\PythonBinding\DLLs)

    - Last step (included in the following example source code): Append the python library directories to your python directory. I guess it is also possible to add the both appended directories by including them to your PATH variable.

    import sys
    sys.path.append("C:\Program Files (x86)\IronPython 2.7\Lib")
    sys.path.append("C:\Program Files (x86)\IronPython 2.7\Lib\site-packages")
    import os
    import numpy as np

    print "Hello, numpy!"

    print np.arange(0,11,1)

    os.system("PAUSE")

  • 10-22-2014 8:57 PM In reply to

    Re: Sharpdevelop and numpy/scipy for ironpython

    Enthoguht has since pulled their copy of NumPy for IronPython from their server. Do you think you can send me a copy of the installers and possibly instructions?

Page 1 of 1 (7 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.