Importing Ladybug Library into GH Python


I am trying to use the ladybug library (PyPi) in GH Python. I also want to use the EPPY library to run EnergyPlus simulation.

I’ve installed the ladybug and eppy libraries through pip install.
I have added the path to grasshopper and it now shows:

[‘C:\Users\gupta\Desktop\My Cloud Offline Files\MSSD\Spring Semester\Design Computation\Assignments’, ‘C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib’, ‘C:\Users\gupta\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib’, ‘C:\Users\gupta\AppData\Roaming\McNeel\Rhinoceros\6.0\scripts’, ‘C:\Users\gupta\AppData\Local\Programs\Python\Python37-32\Lib\site-packages’]

I wrote the following code so far based on the GitHub Usage section:

from ladybug.epw import EPW
weather_data = EPW(epw_path)

location = weather_data.Location

It’s giving me this error:
Runtime error (MissingMemberException): ‘module’ object has no attribute ‘isplus’

line 22, in , “C:\Users\gupta\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\ladybug\”
line 10, in , “C:\Users\gupta\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\ladybug\”
line 5, in , “C:\Users\gupta\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\ladybug\”
line 8, in , “C:\Users\gupta\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\”
line 14, in , “C:\Users\gupta\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\ladybug_comfort_ init .py”
line 37, in import_module, “C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\importlib
init .py”
line 13, in , “C:\Users\gupta\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\ladybug
line 48, in script

Also, the last time I tried to do this, I had added .dll and .gha files in a folder and added the path. This is also consistent with the discussion here:

That had worked but I am not sure where to find the .dll and .gha files for ladybug and eppy. I went with adding the ladybug python files into the Rhino Scripts folder.

The goal of doing this is to set up energy and environmental simulation using python and not the GH Components. I would like to try simulating the incident solar radiation/SED, zone wise loads, heat gain and heat losses for each zone, etc.
I found that ladybug and honeybee have python modules that can be used outside the GH environment. Also, EnergyPlus IDF files can be modified using EPPY. I was trying to use a combination to try simulating using Python. Finally, I want to automate multiple simulations based on changes in input parameters.

As per Mr. Roudsari’s reply, I downloaded the latest version from github. The init file now has the following line addressing this:
for key in lb_plugins:
print(‘Successfully imported Ladybug plugin: {}’.format(key))

This is a variable to check if the library is a [+] library.

setattr(sys.modules[name], ‘isplus’, False)

However, I am still getting the same error. Any help would be appreciated.
Thank You.

What happens if you try outside grasshopper?

Also Rhino/ Grasshopper caches python modules the first time that their are loaded. Did you try to restart both Rhino and Grasshopper?

A better alternative is to use pip --upgrade : pip install --upgrade lbt-ladybug

Finally can you try:

import ladybug

and see if it works.

Hey Mostapha,

Thank you so much for your response. I tried to print the isplus but it is still giving the same error in GH Python.
I also tried Sublime text editor and Jupyter. Please find attached the screenshot of the error from Jupyter.
The isplus bit exists in the init file now. I did

pip install --upgrade lbt-ladybug

Please let me know what I can do to solve this issue.

Here is a screenshot of the error from the Print command.

I uninstalled everything and reinstalled the library. Its working!! Thank you so much for your support.

1 Like