Help with Rhino-stubs?

Hi All, I wonder if someone might be able to help with some Rhino-stubs issues I’m having?

for context, this is for Python, on a Mac, OS Mojave, 10.14.13, Macbook Pro mid-2015

I am able to pip install the stubs just fine I think. So when I start a clean virtual env, all seems fine:

and it did seem to install, if I check the venv packages:

And in VS Code, if I “import Rhino” I am able to get autocomplete working, which seems awesome:

But the trouble I am having is that if I actually go to ‘use’ the new PY file outside Rhino, I get errors about being unable to locate the module Rhino. For instance, if I try and do any testing using pytest which references any file that uses “import Rhino” I get Errors:

using the file inside Rhino/GH is all fine - its just if I try and do anything ‘outside’ Rhino that I get these errors. I wonder if anyone can spot where I’m going wrong here in my setup / configuration? If it helps, for this simple example the directory structure just looks like:

and of course, if I remove that “import Rhino” reference my test works properly

am I supposed to be adding anything to the ‘extraPaths’ config? Or should I be setting some other environment variable someplace? Can’t quite seem to get it sorted I’m afraid. Any thoughts are much appreciated!


This is expected. Stubs are not the true implementation and are only there to help with regards to features like autocomplete. You still need to run scripts that reference Rhino and Grasshopper inside of the Rhino process.

Hi @stevebaer,

Ah - gotcha. Ok thanks. So long as I wasn’t missing something really easy/obvious.
Can I ask: have you ever seen any good solutions for testing in this type of situation? Any examples that I might be able to take a look at?

regardless, thanks for the clarification!

It’s a Windows only solution, but you could try Rhino.Inside CPython

thanks @stevebaer - I’ll give that a whirl.