I want to install some extra libraries to my GH-Python. Some websites support direct downloads, some offers just codeblocks. Is there anywhere a special folder like the plug-in folgerf or GH? What is Pip and is it part of the standard pre-installed python content in GH?
Where is the GH-Python-Language stored?
Maybe someone can explain the hole structure of adding modules/libraries (same?) to Python?
I already read these two posts. The thing is, that I am not sure what exactly defines the module? I went to GitHub - networkx/networkx: Network Analysis in Python and downloaded the hole thing. Then I importet in Rhino like you recommended in the first post.
Then I tried to call the module in GH-Python with " import networkx " but I get the error that the module does not exist.
One more question. Let’s say I want to share to Code with another person, that has not installed the module I am calling in my script. Is there any way to “internalise” the module? What is the best way to work with that.
Hello,
Networkx requires Python 3.5 or greater https://github.com/networkx/networkx/blob/master/INSTALL.rst probably CPython only.
Rhino and gh use Ironpython 2.7 so i’m Afraid you can’t use this or indeed most scientific libraries with Rhino and GH
If you delete the final networkx from your added search path then GH should see it and throw errors because it is not compatible
Did you see this post, you need to extract the folder named networkx and place this in a path that is readable by the Rhino Python interpreter (i.e. by adding it to the module search paths, or directly in the code itself). Have attached networkx 1.5, which will (mostly) work with the IronPython version used by Rhino. If you unzip this to a folder in the module search paths and restart Rhino, you should be good to go.
Edit II: Of course it’s a real shame that versions beyond 1.5 do not (yet) play nice with IronPython. But I’ve used it quite a lot for many different things, and have yet to find a better (in terms of features, versatility and simplicity) graph library for use with GHPython (including QuickGraph). Also note that you can “patch” it, by copying functions from future versions over and implementing these directly.
This is hardly the best solution, but it is very simple and highly explicit. Which in my experience is often better than automagic. I know that @will has been working on automating issuing of dependencies (i.e. with Yak), but I’m not sure if this support Python modules yet.
It depends: I don’t really like to dictate how people structure their modules/libraries, but when issuing to “nOObz” I generally recommend that they use the existing/hard-coded Rhino scripts folder (to avoid having to explain the whole EditPythonScript editor module paths workflow, first thing). I personally use a folder that is synced to my Dropbox, so I always have the same mirror of all my modules on all the systems I work on.
So for most people the path would change when switching the device. ´´
One more option would be to add both paths to the searching paths list, is that correct?
The path is manually entered on each device as you showed above.
You can find the home path programmatically in python with os.path.expanduser("~")
It is apparently possible to find the dropbox path as well!