Pandas on gh for Rh8?

Hello everyone and team of Rh developers,

I searched among some topics to find any possible solution for installing pip packages on gh (Rh8 script component) but couldn’t find any updated ones.

Is there any updates? I’ve noticed that numPy and matplotlib are installed(I think built-in) but how is it possible to add other packages?

Thanks

1 Like

I was able to use pandas by adding it as requirement before importing it:

# r: pandas

import pandas

Thank you for your answer.

How does it work?

Just # r: pandas? Don’t we need to install it through cmd?

In Rhino 8 when you use a Python 3 script that will do it for you.

But there is red one for me here. Can you explain a bit more specific? I have Rh8.

These are the results I have.

pandas error2

And there is another question that I have! Where is the files directory for pandas? I mean the location for envs or packages? So that I can load it from there.

The error logs should tell you what is going on.

This is what it says: AttributeError: partially initialized module ‘pandas’ has no attribute ‘_pandas_datetime_CAPI’ (most likely due to a circular import)

Oh, I tried to install it from cmd to “site-rhinoghpython” is there a duplicate that causing this problem?

I don’t know enough of the inner workings of the Python 3 integration to be able to tell. That is a question for @eirannejad

1 Like

This may resolve the issue:

import locale
locale.setlocale(locale.LC_ALL, 'en_US')
import pandas
2 Likes

Thank you very much it is completely loaded. :pray:

Hello again sir,
I tried to load matplotlib.pyplot.show() to test if other packages are possible to load in gh, but unfortunately after that I couldn’t load pandas again! Can you please kindly check this screenshot and help me again?

What seems to be the problem? I don’t see any errors in script editor

plt.show() doesn’t work for some reason (it works, but the window that should show the plot disappears very fast). You can use plt.savefig() instead, like this example:

The code runs, but the window that shows the plot appears and disappears in 0.1 second. You can see the icon of it in the taskbar when you run it continuously, but there is nothing to see. It should be in another thread, but when I try to use selenium and especially webdriver.wait(), the grasshopper can’t handle it and freezes.maybe there is problem with external windows.

1 Like

@sadra Yes external windows need a rhino backend for matplotlib that I have a ticket for to get fixed:

RH-74046 CPython matplotlib needs a Rhino/Eto backend probably (affects pandas)

1 Like