Hi! Apparntly, Rhino 8 still doesn’t have a date for release. I wonder, CPython is solely a feature of Rhino 8 or could it be released with Rhino 7?
@sadovshikov Python 3 and the new editor are gonna be in Rhino 8
Hey @eirannejad
Needless to say, I am excited about the editor! But cannot use packages yet. I went through the comments above and still miss something very basic, it seems!
So here is my rookie question. I am running the script editor (Rhino WIP) in both Mac and Windows, and when I try to import numpy (or another package from pip), I get this error:
The error on the Windows side says:
Traceback (most recent call last): File “file:///C:/Users/85lpa/.rhinocode/stage/nsyzfugx.1br”, line 30, in NameError: name ‘numpy’ is not defined
I have tried to install the package using “pip install numpy” but same, same.
Do I need to point the ScriptEditor to a special folder? Do I need to switch RhinoWIP to Python 3 somehow?
In our company, we deploy Rhino using Software Centre. Not sure if the custom folder it creates is the culprit here.
Try placing a #
at the beginning of line 30
I would also recommend placing these #r: numpy
statement at the beginning of your script right after #! python3
. This will be a little easier to read.
Hi, is there any way to make matplotlib render figures and plots? Right now using the show() function, it throws the error
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
There is. I have it on my list to create a backend for matplotlib inside of Rhino. The challenge is that Rhino already has a UI with a ui framework and matplotlib ui framework conflicts with that.
RH-74046 CPython matplotlib needs a Rhino/Eto backend probably
Hi, trying to open for the first time. Used RhinoCode and opened ok.
No pop-up[ to ask about installing Python - it did it automatically.
NOw I’m able to click on Menu items at the top and get the dropdowns, but I’m not able to select any of them. Same with buttons in the UI.
Then thought of dragging a .py file from Explorer into the Editor window, and everything became alive.
SysInfo below if it’s of any help:
Rhino 8 SR0 2023-5-23 (Rhino WIP, 8.0.23143.18305, Git hash:master @ d59ac000ad9a8e02537e735edcbee408ac70e442)
License type: Commercial, build 2023-05-23
License details: Cloud Zoo
Expires on: 2023-07-07
Windows 10 (10.0.19045 SR0.0) or greater (Physical RAM: 32Gb)
Computer platform: DESKTOP
Standard graphics configuration.
Primary display and OpenGL: NVIDIA GeForce RTX 3060 (NVidia) Memory: 12GB, Driver date: 4-8-2023 (M-D-Y). OpenGL Ver: 4.6.0 NVIDIA 531.61
> Accelerated graphics device with 4 adapter port(s)
- Windows Main Display attached to adapter port #0
Secondary graphics devices.
NVIDIA GeForce RTX 2070 (NVidia) Memory: 8GB, Driver date: 4-8-2023 (M-D-Y).
> Accelerated graphics device with 4 adapter port(s)
- Secondary monitor attached to adapter port #0
Intel(R) UHD Graphics 630 (Intel) Memory: 1GB, Driver date: 3-3-2023 (M-D-Y).
> Integrated graphics device with 3 adapter port(s)
- There are no monitors attached to this device!
OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On
Graphics level being used: OpenGL 4.6 (primary GPU’s maximum)
Anti-alias mode: 4x
Mip Map Filtering: Linear
Anisotropic Filtering Mode: High
Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 4-8-2023
Driver Version: 31.0.15.3161
Maximum Texture size: 32768 x 32768
Z-Buffer depth: 24 bits
Maximum Viewport size: 32768 x 32768
Total Video Memory: 12 GB
Rhino plugins that do not ship with Rhino
C:\ProgramData\McNeel\Rhinoceros\7.0\Plug-ins\Datasmith Rhino Exporter (d1fdc795-b334-4933-b680-088119cdc6bb)\DatasmithRhino7.rhp “Datasmith Exporter” 5.1.1.0
C:\Users\alanf\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\SafeLayout.rhp “SafeLayout” 1.1.0.2
C:\Users\alanf\AppData\Roaming\McNeel\Rhinoceros\packages\8.0\RPC\0.0.11-beta\RPC.rhp “RPC”
C:\Users\alanf\AppData\Roaming\McNeel\Rhinoceros\packages\8.0\SubstanceImporter\2.0.3\Substance.Win.rhp “SubstanceImporter” 2.0.3.0
C:\Users\alanf\AppData\Roaming\McNeel\Rhinoceros\BlockEditNew\BlockEditNew.rhp “BlockEdit” 1.0.0.0
C:\Users\alanf\AppData\Roaming\McNeel\Rhinoceros\packages\8.0\rhinopbrmaterial\1.1.4+v6.16\RhinoPbrMaterial.rhp “RhinoPbrMaterial” 1.1.2.0
Rhino plugins that ship with Rhino
C:\Program Files\Rhino 8 WIP\Plug-ins\Commands.rhp “Commands” 8.0.23143.18305
C:\Program Files\Rhino 8 WIP\Plug-ins\rdk.rhp “Renderer Development Kit”
C:\Program Files\Rhino 8 WIP\Plug-ins\RhinoBonusTools.rhp “Rhino Bonus Tools”
C:\Program Files\Rhino 8 WIP\Plug-ins\RhinoRenderCycles.rhp “Rhino Render” 8.0.23143.18305
C:\Program Files\Rhino 8 WIP\Plug-ins\rdk_etoui.rhp “RDK_EtoUI” 8.0.23143.18305
C:\Program Files\Rhino 8 WIP\Plug-ins\rdk_ui.rhp “Renderer Development Kit UI”
C:\Program Files\Rhino 8 WIP\Plug-ins\NamedSnapshots.rhp “Snapshots”
C:\Program Files\Rhino 8 WIP\Plug-ins\RhinoCycles.rhp “RhinoCycles” 8.0.23143.18305
C:\Program Files\Rhino 8 WIP\Plug-ins\RhinoCode\RhinoRoslyn.rhp “RhinoRoslyn” 8.0.23143.18305
C:\Program Files\Rhino 8 WIP\Plug-ins\RhinoCode\RhinoCodePlugin.rhp “RhinoCodePlugin” 8.0.23143.18305
C:\Program Files\Rhino 8 WIP\Plug-ins\RhinoCode\RhinoCPython.rhp “RhinoCPython” 8.0.23143.18305
C:\Program Files\Rhino 8 WIP\Plug-ins\Toolbars\Toolbars.rhp “Toolbars” 8.0.23143.18305
C:\Program Files\Rhino 8 WIP\Plug-ins\3dxrhino.rhp “3Dconnexion 3D Mouse”
C:\Program Files\Rhino 8 WIP\Plug-ins\Displacement.rhp “Displacement”
C:\Program Files\Rhino 8 WIP\Plug-ins\ConstraintsUI.rhp “Constraints UI” 8.0.23143.18305
C:\Program Files\Rhino 8 WIP\Plug-ins\SectionTools.rhp “SectionTools”
@eirannejad is it possible yet to get the “rhinoscriptsyntax” help tree (along with the Rhino and Eto ones)
Thx,
Alan
Something that would make the Script Editor more seamless, especially on laptops, is having a keystroke, or the ability to designate them, to toggle between the code editor and the main window, so as to quickly see what effects recent changes are having on the rendered model.
It’d save some routine set up time for some if there was an option to specify the default state of a toggled window element (file explorer, terminal, error message), or even another keystroke to at least spare chronically mobile devs the perfunctory trackpad usage.
I’ve run a lot of python code that causes the script editor, and all of Rhino, to become unresponsive; my code’s super simple, using popular libraries, and thus irrelevant, but what seems noteworthy is that if the Script Editor hangs merely calling it after force-quitting and re-starting Rhino will cause the same problem, and continue to do so. To be clear, Rhino never has any problem launching. The only way I’ve gotten the Script Editor to re-launch with any consistency in this scenario is to rename the file I was working on when the stalling initially occurred. I realize I probably have no idea what’s going on under the hood, it just seems possible that when the Script Editor crashes Rhino then tries to re-initialize the code it previously got hung up on the next time I open the Script Editor feature.
Thanks for soliciting user feedback in this format. Super neat to open the WIP for the first time and see suggestions I had read about here incorporated. The Script Editor is the biggest game changer for me, and allows me to do everything for a project that I’ve had scattered across several clunky platforms for almost a decade in one place🙏
Yes sir. Working on it.
@Allan_Tonias Thanks for reporting this. Would you mind running RhinoCodeLogger
after restarting Rhino (when ScriptEditor has problems launching) and sending me the logs? The logger should have a report of what failed during script editor launch
About the help tree : it is not searchable for now on macOS at least
Not yet. Will add that when python libraries are added. Coming soon
Hello @eirannejad and thanks again for the great work in progress,
Is it already possible to mimic the behavior of the previous GHPython Script component of having “show code input parameter” option ? I’d like to externalise my code as much as possible.
Also can you give us a timeline for custom package installation option ? here we use something like :
“–find-links https://download.pytorch.org/whl/torch_stable.html” in the requirement file.
Lastly, is there a way to “restart script engine” as the regular python editor does without breaking everything ? I tried "Reset CPython runtime but it deleted all my installed libs and now the editor shows an error “Error occurred during language initialisation” …
I use this “restart script engine” option whenever I modify a uils.py file that is imorted by my scripts inside rhino because for some reason it is not properly updated without it.
I know that’s a lot of topics but I’m still exploring
Hi @eirannejad, @stevebaer and others,
I’m very happy that Python 3.9 will be available in Rhino 8!
I’ve given Python 3.9 in Rhino 8 a try in the ScriptEditor in Rhino and in Grasshopper 1. As a result, I have some questions on how to achieve some things and how Python 3.9 in Rhino 8 works exactly.
(1) Given that the latest IronPython release is IronPython 3.4, Rhino 8 will run a normal Python 3.9 installation, right?
(2) How can I install packages that are not (yet) published on PyPI.org, e.g. from a git repo?
I tried:
# requirements: git+https://github.com/account-name/repo-name.git
Which gave me the error:
1. Solution exception:Error installing: git+https://github.com/account-name/repo-name.git==* | System.IO.IOException: The filename, directory name, or volume label syntax is incorrect. : 'C:\Users\User.Name\.rhinocode\python3.9-30\site-envs\default-_AK1kkIt\git+https:\github.com\account-name'
at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
at System.IO.Enumeration.FileSystemEnumerator`1.Init()
at System.IO.Enumeration.FileSystemEnumerableFactory.UserDirectories(String directory, String expression, EnumerationOptions options)
at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
at Rhino.Runtime.Code.Languages.PythonNet.CPythonEnviron.RunUninstall(IEnumerable`1 pkgSpecs)
What I especially find weird about this error is the path mentioned in the first line of the error:
C:\Users\User.Name\.rhinocode\python3.9-30\site-envs\default-_AK1kkIt\git+https:\github.com\account-name
(2.1) Do you use pip
for installing Python packages in the Python 3.9 environment of Rhino 8?
If so, I would have thought that the path name mentioned above should end with the name = "package-name"
variable from the setup.py
, right?
I’m very interested in knowing how you install packages in the Rhino 8 Python 3.9 environment
Next I have some suggestions, or “why not like this” questions:
(1) I really like the way ArcGIS Pro handles Python integration. ArcGIS Pro comes with an installation of conda
, a GUI for managing Python environments and packages with conda
(see images below) and an ArcGIS Pro Python Command Prompt (+ docs) for advanced users.
When you want to install additional Python packages for use with ArcGIS Pro, you have to create a new Python environment, for which you have to clone the Python environment that comes with ArcGIS Pro by default (see the warning in img 1 & img 2 above). This way, users cannot mess up the original Python environment, but do have the freedom to experiment with different Python environments and install any package they want.
(2) If you want to keep the requirements of a Python 3 script in Rhino 8 contained in the script, what about putting the requirements.txt
or conda-env.yml
in a
__requirements__ = [
"numpy",
"git+https://github.com/account-name/repo-name.git",
"etc"
]
or
__env__ = """
name: conda-env-name
dependencies:
- python=3.7
- pandas
- pip:
- git+https://github.com/account-name/repo-name.git
"""
“dunder” (double underscore) variable?
My colleague thought of using a dunder variable, because dunder variables convey information to the Python interpreter, and because it’s easy to overlook # Python comments
, because they are normally not essential to the executability of the code.
No matter my comments above, I’m very happy that Python 3 is coming to Rhino!
As for the ability to load/save the code from GHPython script with new editor it is actually possible to link it to an outside file right now by saving from the editor. Then even outside rhino modifications will be taken into account. BUT if you copy/paste the component in order to have several components linked to the same file, the link in the second component is broken. You can see that it does refer to an external file anymore. Is this intended behaviour ? Is there a copy component option to keep the link with the external python file ?
Thanks again
@thomas.pitiot Hold Shift and right-click on the component and activate Script
input. Then either put the script text in a panel and feed into as many Script components this way, or put the path of the script in a panel and feed into this parameter.
If placing script text in a panel, make sure to add the language specifier line as #! python 3
for this example so the component can determine the language:
If using external paths, make sure to right-click on Script
parameter and set that and Input is Path
. In this example, external.py
is a python file in the same directory as the grasshopper definition so the path is relative and full path is automatically computed:
-
Yes. Rhino8 is using embedded deployment of Python 3.9 at the moment. We probably will upgrade to 3.10 before release
-
There is no option to install unlisted packages at the moment. But you can add the search path to
sys.path
on top of your script and the package will be loaded
2.1) Yes. Currently pip
is used. Installing and deploying conda is very complicated and has lots of options. It makes sense for more scientific applications like ArcGIS. I have a ticket on my list however to implement condo as a package manager option RH-66284
I appreciate all your input on the packages that you use with conda mostly that might have troubles getting installed using pip