BUG - Script Editor - Opens Python 3 Instead Of Python 2


When opening a script that was saved as Python2 the script editor defaults to Python3 language and sets the tab icon accordingly as well.

When the code is executed, instead of running as Python2 it runs as Python3 which of course can lead to compatibility errors for certain scripts.

My current workaround is to copy the code from the opened “py3” tab to a new “py2” tab and paste.

Not the end of the world but certainly an inconvenience each time…

Do you see this on your end @eirannejad ?

Thank you!

Not really. How was the original script “saved as Python2”? Does it say #! python 2 somewhere on the first 32 lines of the script?

1 Like

Thanks for your response @eirannejad ,

It does not, I can repeat the issue with the following steps:

  1. Open ScriptEditor in Rhino

  2. Create New IronPython2 script

  3. Save to file somewhere

  4. Close and reopen Rhino

  5. Open ScriptEditor

  6. File Open → Choose the IPy2 file

  7. It will be Py3 now… (on my end)

Ok I don’t know what am I doing that different. So this exact process will open the untitled.py with python 3 ??

1 Like

Ahh, I see, you NEED to add the line

#! python 2

I did not have this in the script. Now it seems to work.

Thank you!

1 Like

Ya either that or save the script in .py2 extension :smiley:

1 Like

Ahh… I see. I guess I was expecting the script editor to save it in .py2 by default if the New file created a .py2 file.

Wish list for a future update? :upside_down_face:

I decided not to do that since it’s not a ‘known’ file extension in python and windows explorer does not show an icon for it. :man_shrugging: The safe way is to always include the #! python 2 at the top.

1 Like

Thanks for the explanation, that makes sense! Wish removed haha

1 Like