How to use networkX library in python of grasshopper?

Can we install networkX library for python in Grasshopper? the version of python inside the grasshopper is 2.7.12,

If you’re using Rhino 8, you can use the new script components and easily install NetworkX or any other CPython library.

#r: networkx

You can find an older version of NetworkX which supports Python 2.7.

2 Likes

Note that some functionality of NetworkX 2.2 needs additional libraries, compiled in C, which will not work in IronPython in Grasshopper

2 Likes

Thanks a lot dear Mahdiyar, I’m using Rhino 7, but I think I should use Rhino 8. Nice solution

I installed the Rhino8 , just now I cant install the networkx, it is mentioned that I should have the pip, and Install the current release of networkx with pip : pip install networkx
but I cant even install the pip, could you please help me with this?

Any Python package can be installed by simply adding the following line at the beginning of your code:

# r: networkx

The versions of a package can be specified like this:

# r: networkx==3.2.1

It is possible to specify more than one package in this way:

# r: networkx==3.2.1, matplotlib=3.8.2
2 Likes