# Rhino 8 Script Editor does not run IronPython 2 scripts

**URL:** <https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916>\
**Category:** Rhino for Mac\
**Tags:** windows, mac\
**Created:** [January 22, 2024, 10:59pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916 "2024-01-22T22:59:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [January 22, 2024, 10:59pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/1 "2024-01-22T22:59:36Z")

</div>

Hi @eirannejad,

just found by accident that the new script editor does not run IronPython 2 scripts on Mac even when the `#! python 2` line is on top. `EditPythonScript` and `RunPythonScript` both worked.

\_  
c.

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [January 22, 2024, 11:26pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/3 "2024-01-22T23:26:16Z")

</div>

Which version?

---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [January 22, 2024, 11:31pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/4 "2024-01-22T23:31:14Z")

</div>

Hi @eirannejad, it was 8.5.24022.10002 downloaded today.

\_  
c.

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [January 22, 2024, 11:44pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/5 "2024-01-22T23:44:11Z")

</div>

8.5?!?! only 8.3 and 8.4RC are out. Where did 8.5 come from 😃

---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [January 22, 2024, 11:48pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/6 "2024-01-22T23:48:58Z")

</div>

Internal testing for jeff to check a display related problem. I will wait until the official one is out and then test again 😉

\_  
c.

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [January 22, 2024, 11:50pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/7 "2024-01-22T23:50:10Z")

</div>

Ok sweet. I have done some changes to the language spec parser. Tomorrow’s builds (8.4, 8.5) should not have issues 😃

---

<div class="post-metadata">

**Author:** ![jim](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jim/32/570126_2.png) [@jim](https://discourse.mcneel.com/u/jim)\
**Post date:** [January 23, 2024, 12:04am UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/8 "2024-01-23T00:04:15Z")

</div>

> [@clement](#):
>
> Hi @eirannejad,
> 
> just found by accident that the new script editor does not run IronPython 2 scripts on Mac

> [@eirannejad](#):
>
> Which version?

I"m using Rhino version 8.4 currently, but none of my IronPython scripts that run in Rhino7 have ever run on any version of Rhino8. The error messages are every bit as meaningless and cryptic as the " `#! python 2`" line that I stick at the top of the script.

Just to inform you I did translate one of my scripts so that it conforms to python3 and that does run, but it runs 10 times slower than the the python2 version.

The question I have is why would anybody in their right mind use the Rhino8 script editor?  
What is the benefits?

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [January 23, 2024, 10:14pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/9 "2024-01-23T22:14:23Z")

</div>

The original Python 2 EditPythonScript script editor still exists in V8.

It’s true that the new script editor does not seem to like running Py 2 scripts much - I also get all kinds of errors when I try to run some of mine. I assume that will get fixed one of these days, the new script editor is far from being a finished product. It has turned into much more of a hard-core programmer’s interface as opposed to a more lightweight scripting interface, and the emphasis has been for Python 3 from the get-go.

Mostly I run my existing scripts from aliases or toolbar buttons, or from the old script editor.

---

<div class="post-metadata">

**Author:** ![jim](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jim/32/570126_2.png) [@jim](https://discourse.mcneel.com/u/jim)\
**Post date:** [January 23, 2024, 11:32pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/10 "2024-01-23T23:32:34Z")

</div>

> [@Helvetosaur](#):
>
> The original Python 2 EditPythonScript script editor still exists in V8.

Yes I know that, but the topic being discussed is _Rhino 8 Script Editor does not run IronPython 2 scripts_. And McNeel seems to think Rhino 8 Script Editor does run legacy IronPython scripts, so someone should give them a clue.

You would think that when you put the" #! python 2" line at the top of a script, Rhino would run the code that executes a python 2 script correctly, but no, they got **New And Improved** code to run the script so they use that even though it doesn’t work.

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [January 24, 2024, 8:11am UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/11 "2024-01-24T08:11:20Z")

</div>

> [@eirannejad](#):
>
> Tomorrow’s builds (8.4, 8.5) should not have issues 😃

Still not working in todays (8.4.24023.15001, 2024-01-23)

I mostly get errors like this:

```auto
System.NullReferenceException: Object reference not set to an instance of an object.
   at Rhino.Runtime.Code.Languages.PythonNet.CPythonCode.Execute(RunContext context)
   at Rhino.Runtime.Code.Code.ExecTry(RunContext context, IPlatformDocument& doc, Object& docState)
   at Rhino.Runtime.Code.Code.Run(RunContext context)

```

Sometimes the script will actually run and I get that afterwards. But it doesn’t give me a line number where it errors out.

Sometimes I get this:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/c/7/4/c741cbefbb75c4655d5f3e1c842d657f3310210f.png)

Sometimes it will start without an error message, but just not do anything.  
@eirannejad

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [January 24, 2024, 9:09pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/12 "2024-01-24T21:09:41Z")

</div>

@Helvetosaur  
The error is from Python 3 so lets disregard that as it is the wrong python for this script.

I justed tested 8.4.24024.11002 and it is good.

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [January 24, 2024, 9:39pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/13 "2024-01-24T21:39:19Z")

</div>

> [@eirannejad](#):
>
> The error is from Python 3 so lets disregard that as it is the wrong python for this script.

No, let’s not disregard it because I had #! python 2 at the top of the script. I even used File\>New IronPython 2 to open a new template and then pasted the script in, doesn’t work.

> [@eirannejad](#):
>
> I justed tested 8.4.24024.11002 and it is good.

Not here…

---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [January 25, 2024, 1:15am UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/14 "2024-01-25T01:15:02Z")

</div>

> [@Helvetosaur](#):
>
> But it doesn’t give me a line number where it errors out.

Hi @eirannejad, this reminds me of a feature i’am missing from the `EditPythonScript` editor. If an error occurs, the line number is displayed in the terminal and you can double click on it which navigates to the line in the script. Could this be added to the new script editor too please ?

thanks,  
c.

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [January 30, 2024, 12:11am UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/15 "2024-01-30T00:11:21Z")

</div>

I am cleaning up the way editor shows errors so I’ll try to implement this as well

[RH-79256](https://mcneel.myjetbrains.com/youtrack/issue/RH-79256) Improve dealing with errors during debug in script editor

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [February 5, 2024, 4:37pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/16 "2024-02-05T16:37:45Z")

</div>

> [@jim](#):
>
> The question I have is why would anybody in their right mind use the Rhino8 script editor?  
> What is the benefits

> [@Rhino 8 Regression: CPython/IronPython RhinoCommon Performance Is Worse](https://discourse.mcneel.com/t/rhino-8-regression-cpython-ironpython-rhinocommon-performance-is-worse/174926/7):
>
> @AndersDeleuran CPython vs IronPython CPython implementation in Rhino 8 (Custom implementation of [Pythonnet](https://pypi.org/project/pythonnet/) and hereon refered to as Pythonnet) is NOT meant to replace IronPython. These are two completely different implementations of the Python language specification. Each have their own pros and cons: IronPython compiles to dotnet common language runtime (CLR) bytecode, and uses the same type system and managed memory as dotnet runtime and therefore is incredibaly fast once the runtime is …

---

<div class="post-metadata">

**Author:** ![clement](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/clement/32/772979_2.png) [@clement](https://discourse.mcneel.com/u/clement)\
**Post date:** [February 5, 2024, 5:46pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/17 "2024-02-05T17:46:21Z")

</div>

Hi @eirannejad, a small improvement suggestion, please run below from the old `_EditPythonScript` and the new Editor for comparison, note the prompt behavior:

```python
#! python 2

import rhinoscriptsyntax as rs

def DoSomething():
    rs.Prompt("Processing, please wait")
    rs.Sleep(1000)
    
DoSomething()

```

In the old editor, the prompt vanishes once done, it keeps staying with the new one.

Also if you choose from the R8 menu:

> Tools \> Script \> Edit

then cancel and right click the command prompt to see the last command list, it gets a new entry “Edit…”, it would be nicer if this could be more descriptive, same goes for “Run…”. Btw. choosing this from the menu:

> Tools \> Script \> Run

it allows to choose all kinds of file types…

EDIT: here is another small issue, to repeat it please open the old Editor and the new one and run it from the new editor:

```python
#! python 2

import rhinoscriptsyntax as rs
rc = rs.GetString("Enter something")

```

On my system it does not set the focus to the main window (the Command Prompt) but the old editor when i start typing. If only the new editor is open, it works as expected. Maybe this is fixable by using [SetFocusToMainWindow](https://developer.rhino3d.com/api/rhinocommon/rhino.rhinoapp/setfocustomainwindow) ?

thanks,  
c.

---

<div class="post-metadata">

**Author:** ![jim](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jim/32/570126_2.png) [@jim](https://discourse.mcneel.com/u/jim)\
**Post date:** [February 5, 2024, 8:52pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/18 "2024-02-05T20:52:53Z")

</div>

> [@Rhino 8 Regression: CPython/IronPython RhinoCommon Performance Is Worse](https://discourse.mcneel.com/t/rhino-8-regression-cpython-ironpython-rhinocommon-performance-is-worse/174926/7):
>
> IronPython compiles to dotnet common language runtime (CLR) bytecode, and uses the same type system and managed memory as dotnet runtime and therefore is incredibaly fast…

Does this mean there is no hope of ever making the Cpython “incredibaly fast” ?

I notice that for scripts that are compatible with both the new ScriptEditor and the old Rhino Python editor, there is a noticeable difference in speed.

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [February 6, 2024, 3:40pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/19 "2024-02-06T15:40:31Z")

</div>

Ok great. Thanks for reporting this. I’ll test today

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [February 6, 2024, 3:42pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/20 "2024-02-06T15:42:45Z")

</div>

@jim Let’s keep the performance conversation on that thread. There is hope. But the goal is to make it clear that IronPython and Pythonnet in Rhino 8, are two different ways to put Python language in a dotnet Application (Rhino). They are two architectures and each have their own pros and cons.

We will keep improving the performance to get it as fast as possible.

---

<div class="post-metadata">

**Author:** ![eirannejad](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/eirannejad/32/477962_2.png) [@eirannejad](https://discourse.mcneel.com/u/eirannejad)\
**Post date:** [February 6, 2024, 4:28pm UTC](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916/21 "2024-02-06T16:28:37Z")

</div>

[RH-80271](https://mcneel.myjetbrains.com/youtrack/issue/RH-80271) Script Editor does not clear prompt after running script

[RH-80272](https://mcneel.myjetbrains.com/youtrack/issue/RH-80272) Command history is not clear with Script: Run or :Edit commands

[Next page](https://discourse.mcneel.com/t/rhino-8-script-editor-does-not-run-ironpython-2-scripts/173916.md?page=2)
