Not able to package Python dependencies inside a GH plugin

Hello community,

I am new to plugin development using the Script Editor, and have followed both the guide by @eirannejad and the tips on this thread Grasshopper Plugin running Python - #6 by eirannejad in order to package a few python3 components as a plugin to be distributed to students for a workshop.

The components run on a venv and use dependencies such as Pandas, Numpy, Scipy, XLRD, Matplotlib and Seaborn. The problem is :

  • Compiling the plugin without the python libraries is quick, but they don’t work as they miss the python libraries (duh.!)
  • Adding the python libraries to the project (as one should , by pointing to the packages here C:\Users\USER\.rhinocode\py39-rh8\site-envs\RAW-OJ5x0e2P) and the Script Editor freezes on “preparing python libraries” and never compiles. It has been left overnight (10hours) and same progress bar.
  • I have tried adding only one of the libraries ( and not all 20+ of them) and i get the same problem. it is stuck on “preparing assembly” even though the logs says
    Info 10/17/2025 08:42:24 [RhinoCode] Stubs already exist for Microsoft.VisualBasic.Forms, Version=8.0.0.0

Info 10/17/2025 08:49:43 [RhinoCode] Added library Rhino.Runtime.Code.Languages.PythonNet.CPythonModule to active project

Am i doing something wrong ? is there a bug ? Any help is much appreciated :slight_smile:

I upload screenshot as well as the logs. Running Rhino 8 SR22 2025-8-5 (Rhino 8, 8.22.25217.12451, Git hash:master @ 96429e6361004c775c

log.txt (25.4 KB)

update: i have tried not adding the libraries at all and using #r in each component instead of the #venv, the plugin compiles but the components dont work, as if the libraries are not loading - and therefore a dataframe is not recognized as such

What do you mean by “compiling” when you say “Compiling the plugin” and “the plugin compiles”?

CPython components don’t need to be compiled. They might just need their depenencies installing into a venv. It’s possible to compile IronPython components that only use Pure Python code, but it’s a lot of work, and won’t work with C extensions.

They don’t need to be, but CPython components can be compiled, just the way that was shown in the Post/Tutorial linked by Gabriella.

As for the issue: Unfortunately can’t offer a fix besides the “known ones” (i.e. delete .rhinocode completely and re-initialize, which did not work for me).

But I can confirm similar issues with freezes and/or things getting stuck during Compilation as well as during # r: installations.

Over here, package installs freeze Rhino completely. If the process is killed, the package is actually installed. It seems Rhino never exits the installing package mode, which seems similar.

EDIT!

I picked up a hint from this thread, with which I could at least solve the installation-freeze issue! It seems to be charset_normalizer. I had an environment like this:

# -*- coding: utf-8 -*-
#! python3
# venv: DDU_CSC
# r: requests==2.32.5
# r: numpy==2.0.2
# r: scipy==1.13.1
# r: scikit-learn==1.6.1
# r: robust-laplacian==1.0.0

this always freezed everything during installation, like I said. As soon as I explecitly added charset_normalizer like this:

# -*- coding: utf-8 -*-
#! python3
# venv: DDU_CSC
# r: charset_normalizer
# r: requests==2.32.5
# r: numpy==2.0.2
# r: scipy==1.13.1
# r: scikit-learn==1.6.1
# r: robust-laplacian==1.0.0

…my environment installs without a problem! Maybe this works for your case, too? You mentioned you had around ~20 dependencies, so maybe one of them has charset_normalizer as requirement?! It’s just a hunch!

I hope @eirannejad might be able to shine some light on this, as we are also in the process of deploying for upcoming student workshops :smiley:

Best, Max

apologies @James_Parrott , i meant “build / export / publish” the plugin.

FYI @efestwin Max the current workaround we have used is to export our components as ghuser files and distribute those to the students.

With the caveat that - we have seen happen on student laptops:
a code with the following lines

#venv: CITA >> this initializes the venv in the rhinocode directory

#r : pandas, seaborn, scipy, xlrd >> this installs the packages in the default environment, not the venv we just created

it ends up working, but it is ignoring the venv essentially

to install libraries in the venv one has to actually run the code with

#venv :CITA

print(“OK”)
and then go and click the package icon and manually install the packages.

@eirannejad i hope you can have some time to explain what we are doing wrong, and what to do instead

Oh this is super helpful thank you!

So far I didn’t have this issue but with the workshops coming up this could save me hours in case it happens! :folded_hands:

Thanks. I hadn’t realised that.