algorithmic modeling for Rhino

This discussion is somewhere between a  bug and a feature request.

Using GhPython, I recently tried to import a python package that I've used before: networkx

I get this error:

"Runtime error (MissingMemberException): 'module' object has no attribute '_getframe'"

A little bit of searching leads me to understand that the ability of a script to access its "frame" can be switched on or off by properties that are passed to the IronPython Engine upon instantiation:

var options = new Dictionary<string, object>(); 
options["Frames"] = true;
options["FullFrames"] = true;
ScriptEngine engine = Python.CreateEngine(options);

This seems like a harmless and helpful change to the RhinoPython implementation, which would allow a greater use of third-party python packages. Is there any possibility of changing the current implementation?

Views: 2134

Replies to This Discussion

I would try to edit this myself, but I can't seem to find the IronPython engine implementation in the source code.

Hi Ben,

I've been/am using NetworkX quite a lot lately as well. I have however not experienced the error you're getting and would like to avoid it if possible. I assume that this might occur due to us using different versions of the involved applications/modules. My current setup:

Rhino: Version 5 SR3 (5.3.30426.17065, 04/26/2013)  
GH: 0.9.0056
NetworkX: 1.5

I forget, but seem to vaguely remember having problems running NetworkX 1.7 within Rhino when I was first was testing it out last summer/fall. Edit: Just updated to 1.7 and it is indeed the same error. Will roll back to 1.5 for now. Also, kudos on your suggestion :)



Thanks Anders, using 1.5 worked!

I was using

Rhino: Version 5 SR4 (5.4.30524.11065, 05/24/2013)

GH: 0.9.0014

I'm not sure which GhPython it is. Is there a way to check?

I had tried NetworkX 1.7, 1.6, and 1.1, but all of them had the same error. I had assumed there would be no difference between 1.1 and 1.6.

Great, hope you won't be missing too many features from 1.7.

You can check the GHPython component version by opening the editor, the version number should be displayed in the lower right corner.

I just checked out the NetworkX release log. It only mentions IronPython compatibility from 1.2. Perhaps this is why 1.1 gave you an error. Either way, would be good to get this sorted out so that we can benefit from the (almost) full range of Python goodies out there. Fingers crossed!

Hey Anders,

I've been trying to get NetworkX to import into a plain old python component in GH and no luck. I downloaded the egg version of 1.5 for Python 2.6 and 2.7, unzipped, and copied into my IronPython site-packages folder. Neither works.

I have a very simple class I wrote in VisualStudio2015 which I can import from this same folder, so Rhino is clearly reading the folder.

When I try to import, though, it says it can't find the module.

Any ideas? I'd like to start coding in VisualStudio with a few modules, but if the code can't access the same modules from GH, I'm out of luck.

Thanks, David

Try downloading this zip file and unzipping it to this folder:


Then restart Rhino/Grasshopper, open up a GHPython editor, type and run:

import networkx

Does this work for you?

Brilliant!! Thanks so much. Two quick follow up questions if you have time...

1. Do you think installing multiple IDE's and versions of IronPython / Python might cause the problem, or is this simply and issue of putting the right version of networkx into the right folder?

2. Not related really: Inside the Python editor in GH, once you create a variable from a class, you cannot get autocomplete to come up when you use dot-notation on the variable unless, for some reason, it gets passed into another Python component. In C# new classes/objects immediately have their properties accessible through typical dot-notation. Is this not possible in Python?

No worries David. Hope it helped.

1. It could be an issue if you get your paths mixed up. Some Python distributions (Anaconda, Enthought) do some pretty systemwide stuff, which might fuck with your RhinoPython setup. That said, placing modules either in the default RhinoPython folder (as per above) or in a custom folder (editPythonScript editor -> Tools -> Options -> Module Search Paths), should both work. So yes, it's all about putting it in the right folder and unzipping it correctly :)

2. Intellisense in GHPython only seems to work when an object "knows what it is". That is, when it comes straight from a namespace (like say import Rhino) or when passed as a component input parameter. There might be other cases. My best piece of advice is to never rely on intellisense, but a couple of very useful Python functions. See my reply here and the links.

Thanks for the feedback. The introspection you linked to is very helpful, though admittedly I rely very heavily on intellisense given that I don't code all that often, or do so intermittently.

Thanks again for all the help... I will pass this on to others

hi anders,

your download link is dead. could you please update it?



I think this is it:






  • Add Photos
  • View All


  • Add Videos
  • View All

© 2023   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service