[Ironpython-users] SymPy and IronPython 2.7.4

Andreas Beham andreas.beham at heuristiclab.com
Mon Apr 7 13:58:23 CEST 2014


Hi,

I've not had problems running SimPy samples with IronPython. In fact, I
copied the MachineShop sample from their page and added it to a Python
project in VS2013 (you need to have PythonTools for Visual Studio installed
to do this). I could run that Python project without problems. I also ran
the model within our own environment in which I integrated IronPython-based
script execution recently. I could run the model without problems. Of course
you have to do some imports first:
import sys
sys.path.append(r"C:\Program Files (x86)\IronPython 2.7\Lib")
sys.path.append(r"C:\somepath\simpy-3.0.3")

Btw, I've also created a .NET port of SimPy, named SimSharp, which you might
be interested in:
https://github.com/abeham/SimSharp
It's not a 1:1 port, but I tried to port the basic concept of using an
iterator to model a process.

Sincerely,
Andreas

-----Ursprüngliche Nachricht-----
Von: Ironpython-users
[mailto:ironpython-users-bounces+andreas.beham=heuristiclab.com at python.org]
Im Auftrag von Andrew Ayre
Gesendet: Montag, 07. April 2014 12:03
An: ironpython-users at python.org
Betreff: [Ironpython-users] SymPy and IronPython 2.7.4

Hello,

I have embedded IronPython 2.7.4 into a .NET 4.0 C# application. I can enter
and run scripts and I also have an interactive console. It's working great
and I have no issues... until I tried to use SymPy.

I've asked for help from the SymPy people but they don't have any experience
with IronPython.

I have a subfolder called PythonLib into which I have copied the 2.7
standard libraries. Importing from these works:

========================================================
>>>import xml.dom
>>>
========================================================

So I have copied SymPy into PythonLib as well (e.g. I have
\PythonLib\sympy\__init__.py).

Here is the first issue:

========================================================
>>>import sympy

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\__init__.py",
line 32, in <module>
  File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy
\core\__init__.py", line 8, in <module>
  File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\expr.py",
line 7, in <module>
  File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\evalf.py",
line 27, in <module>
  File
"C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\containers.py",
line 14, in <module>
  File
"C:\Users\Andy\Documents\ADScript\PythonLib\sympy\utilities\__init__.py",
line 17, in <module>
  File
"C:\Users\Andy\Documents\ADScript\PythonLib\sympy\utilities\timeutils.py",
line 11, in <module>
  File
"C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\compatibility.py",
line 110, in u
TypeError: unicode_escape_decode() takes no arguments (1 given)
========================================================

I can't find any description of what unicode_escape_decode does. It seems to
be a built-in function? In general SymPy is passing a string to it to be
decoded so it appears to make sense that the function has an argument.

I've worked around this with the following:

========================================================
>>>import codecs
>>>def my_unicode_escape_decode(x):
...    return x
...
>>>codecs.unicode_escape_decode = my_unicode_escape_decode
========================================================

Now I get attribute errors. Here is the result of running several imports.
Can anyone please give me some pointers as to what might be the issue? I'm
thinking it is something to do with my environment or the way I am embedded
IronPython. Thanks! Andy

========================================================
>>>import sympy

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\__init__.py",
line 32, in <module>
  File
"C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\__init__.py",
line 8, in <module>
  File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\expr.py",
line 7, in <module>
  File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\evalf.py",
line 9, in <module>
AttributeError: 'module' object has no attribute 'mpmath'

>>>import sympy.mpmath.libmp as libmp

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\__init__.py",
line 34, in <module>
  File
"C:\Users\Andy\Documents\ADScript\PythonLib\sympy\assumptions\__init__.py",
line 2, in <module>
  File
"C:\Users\Andy\Documents\ADScript\PythonLib\sympy\assumptions\ask.py",
line 323, in <module>
  File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\cache.py",
line 93, in wrapper
  File
"C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\function.py",
line 185, in __new__
ImportError: No module named fancysets

>>>from sympy.sets.fancysets import Naturals0

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\__init__.py",
line 32, in <module>
  File
"C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\__init__.py",
line 8, in <module>
  File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\expr.py",
line 7, in <module>
  File "C:\Users\Andy\Documents\ADScript\PythonLib\sympy\core\evalf.py",
line 9, in <module>
AttributeError: 'module' object has no attribute 'mpmath'


>>>sys.path

['.', 'C:\\Users\\Andy\\Documents\\ADScript\\bin\\Debug\\Lib',
'C:\\Users\\Andy\\Documents\\ADScript\\bin\\Debug\\DLLs',
'C:\\Users\\Andy\\Documents\\ADScript\\bin\\Debug\\PythonLib',
'../../PythonLib']
========================================================

--
Andy
PGP Key ID: 0xDC1B5864
_______________________________________________
Ironpython-users mailing list
Ironpython-users at python.org
https://mail.python.org/mailman/listinfo/ironpython-users



More information about the Ironpython-users mailing list