Is it possible install and import Matplotlib, Tkinter, SymPy into IronPython for use in Rhino?
Asked Answered
K

0

8

Question is as title says. Working on a project that requires Sympy, Matplotlib and Tkinter to be imported through IronPython. The code will be run in Rhino, which uses Python 2.7. Is there any way to do this? I've seen a 2014 question that says that Tkinter just doesn't work in IronPython but perhaps things have improved since then.

SymPy is the most crucial library that needs to be imported. Have checked around the documentation, but it's a bit unclear.

Update

So I've been able to install pythonnet into my python interpreter, after much finagling with a .whl file instead on cmd. Now we're running into the following error when we try to import clr in Anaconda (Python 2.7):

So after the following code snippet is compiled -

import clr  
clr.AddReference("System.Windows.Forms")
from System import String
from System.Collections import *
from System.Windows.Forms import Form

print "Hello"

We get this error:

'import sitecustomize' failed; use -v for traceback
Hello 

Any code below the import statements still runs (thus the 'Hello'), but I'd like to know what this error means or what is causing it. Thanks in advance.

*Another Update**

Posted on the Rhino Forums, apparently there's been no changes yet in Rhino's IronPython implementation to make it able to reference previously incompatible libraries. They recommended using Eto instead. Thanks for the help!

Kaykaya answered 20/1, 2017 at 8:24 Comment(9)
Have you tried pythonnet?Hercule
Not yet, but would pythonnet need to be installed through the IronPython module linked up to Rhino or command prompt?Kaykaya
you will have to install pythonnet using CPython. then call Rhino_DotNET.dll from CPython interpreter.Hercule
Have spent a day trying to figure out how to install the package based on the github code. Put Python.Runtime.dll.config in my dll files for CPython 2.7, but couldn't find the clr.pyd file (unless it's the clr.py file, in which case I tried to change it to a .py file but we'll see if that works). For some reason I can't locate nPython.exe. What's the best way to go about installing Pythonnet in Python 2.7 (or Anaconda with Python 2.7)? Sorry if this is a question with a very obvious answer.Kaykaya
Your error is likely due to blocked ports with firewall.Hercule
https://mcmap.net/q/1474271/-39-import-sitecustomize-39-failed-upon-starting-spyderHercule
The proper way to install pythonnet is pip install pythonnet -UHercule
When you refer to Cpython Interpreter, you mean something like Ipython in Anaconda that's a Python 2.7 version, right? Is there a way to import matplotlib and tkinter into the RhinoPython console itself, rather than coding it from an outside interpreter? I.e. Running matplotlib and tkinter directly in the RhinoPython console.Kaykaya
Contact Rhino support or their forum, I don't know how RhinoPython works.Hercule

© 2022 - 2024 — McMap. All rights reserved.