Honeybee-ph Causing Error

Hi,

I tried to download the grasshopper honeybee-ph addin through the installer script without success. I then copied the “honeybee_grasshopper_ph” folder containing the “src” and “user_objects” directories to: C:\Program Files\ladybug_tools\grasshopper

This seems to work for the add-in but now it throws the following error in the Pollination Rhino environment:

error.zip (2.8 KB)

What’s the best way to fix this? The “Run as Admin” to install the Honeybee-Ph worked only when you ran Rhino as admin again, when opening Rhino normally the add-in did not appear.

Hi @smarentette ,

I’m sorry about the trouble there. Certainly happy to take a look and see if its something we can fix. To be honest we have not tested the Honeybee-PH plugin with Pollination: our office is all MacOS so we can’t use Pollination - so it’s only ever been tested to work with the ‘normal’ (local) Ladybug Tools Grasshopper environment.


For the installation:
If you are using Pollination, I am assuming your ladybug_tools is installed in C:\Program Files\ladybug_tools\ - correct? So in that case you would need to:

  1. Put all of the various honeybee-ph python libraries (and dependencies) into: C:\Program Files\ladybug_tools\python\Lib\site-packages\...

  2. Put the Honeybee-PH Grasshopper Components into: C:\Users\{your-user-name}\AppData\Roaming\Grasshopper\UserObjects\...

In most cases the ‘Installer’ is able to handle all of that and put all the bits in the right spots. But I imagine that you are on some sort of company system where there are multiple users, and so the admin install isn’t working correctly? Is that right? I’m sorry about that - it definitely makes the configuration more complex for sure!


The challenge is that if you can’t pip install ... the libraries, then configuring all the elements manually is going to be really tough. There are several dependencies that also need to get installed alongside the core honeybee-ph libraries.

Were you able to install everything into the ‘admin’ account on your computer? Is that where you are copy/pasting the libraries here from?

@edmay

Thanks @edmay,

I am able to use pip to install. But I cant change the path it installs the libs

c:\users{user-name}\appdata\roaming\python\python39\site-packages

my site-packages folder contains the libs you show:

This still gives the following error when any Pollination commands are used:

I downloaded the “honeybee_grasshopper_ph” from your github.

Ah - ok, then in that case, since you are able to pip install to the other location, the relevant dependencies you would need to copy over include:

  • annotated-types
  • appscript
  • click
  • honeybee-core
  • honeybee-energy
  • honeybee-ph
  • honeybee_ph_plus_rhino
  • honeybee_ph_rhino
  • honeybee-schema
  • honeybee-standards
  • ladybug-core
  • ladybug-display
  • ladybug-geometry
  • ladybug-geometry-polyskel
  • ladybug-rhino
  • lxml
  • markdown-it-py
  • mdurl
  • PH-units
  • PHX
  • psutil
  • pydantic
  • pydantic-openapi-helper
  • pydantic_core
  • Pygments
  • rich
  • typing_extensions
  • xlwings

that is all the dependencies needed by honeybee-ph, as well as the core libraries themselves. All of those should have been installed in your other folder (I hope)?

If you are able to move all of those into your working directory, does that fix the issue here?

@edmay

All of those libs are in C:\Program Files\ladybug_tools\python\Lib\site-packages

Still no luck…

shoot. Sorry. The only other thing to maybe try, just to see its still a configratiopn problem, is to drag an HB-PH Grasshopper component onto the canvas? If its glowing red and yelling about things, it could still be a config issue. If it works in GH, it must just not be compatible with the Pollination Rhino Tool.

Although… I don’t really understand the error, now as I look at it?

Traceback (most recent call last):
  File "C:\Program Files\ladybug_tools\python\lib\site-packages\honeybee_energy_ph\load\ph_equipment.py", line 19, in <module>
    from honeybee_energy.properties.room import RoomEnergyProperties
  File "C:\Program Files\ladybug_tools\python\lib\site-packages\honeybee_energy\properties\room.py", line 33, in <module>
    from ..hvac import HVAC_TYPES_DICT
  File "C:\Program Files\ladybug_tools\python\lib\site-packages\honeybee_energy\hvac\__init__.py", line 11, in <module>
    from .idealair import IdealAirSystem
  File "C:\Program Files\ladybug_tools\python\lib\site-packages\honeybee_energy\hvac\idealair.py", line 7, in <module>
    from honeybee.altnumber import autosize, no_limit
ImportError: cannot import name 'autosize' from 'honeybee.altnumber' (C:\Program Files\ladybug_tools\python\lib\site-packages\honeybee\altnumber.py)

I don’t see what this autosize object is that is causing the issue?

It is not in the honeybee.altnumber module, unless I’m missing something?

And weirdly, VSCode cannot find it either…

and yet… it does exist in GH…

@chriswmackey , is there some black magic happening here with autosize that I’m missing?

@edmay

Thanks for trying to answer this, @edmay .

I also have not tested honeybee-ph with our pollination setup but it should all be feasible since it’s effectively the same as food4rhino installer. Just in a different place on the machine.

Looking at the traceback, it appears that honeybee_energy_ph might be trying to load the Autosize object from honeybee.altnumber before honeybee_energy has gotten the chance to inject it into the module. This is supposed to happen upon import of honeybee_energy here in the code:

But, for some reason, it is not happening correctly on @smarentette 's machine.

For what it’s worth, I just ran the honeybee-grasshopper-ph installer here using Rhino in Admin mode and I have no issues with either honeybee-ph or Pollination Rhino.

So I am inclined to think, @smarentette, that whatever is preventing you from running the Grasshopper installer correctly on your machine is probably the same thing that is giving you problems with your current installation.

What error are you getting when you try to to run the honeybee-grasshopper-ph installer definition with Rhino in Admin mode?

Hi @smarentette,

If you use the pip command from the ladybug-tools installation it should install the libraries in the right location. Open the CMD as an administrator and run this command.

"c:\Program Files\ladybug_tools\python\python.exe" -m pip install honeybee-ph -U

Now to solve the other problem, as @chriswmackey mentioned, this issue is most likely happening because of the order in which honeybee is loading the extensions. honeybee-energy-ph shows up before honeybee-energy in the list. To fix this add import honeybee_energy._extend_honeybee to the top of C:\Program Files\ladybug_tools\python\Lib\site-packages\honeybee_ph\__init__.py and before importing honeybee_ph modules.

That should resolve the problem.

@edmay, you may want to consider a similar modification in the honeybee-ph source code. Thank you for all the great work!

Thanks, @mostapha . You are right that @edmay needs to make a change to his source code.

I was able to recreate the error. I just needed to run one of the commands that tries to access any of the recourse managers like PO_ConstructionManager.

Because @edmay is importing honeybee energy at the top of extend_honeybee_energy_ph.py, I thought that the import order should be resolving itself. But it looks like he’s trying to access features of honeybee-energy in the other packages he has like honeybee-ph, honeybee-ph-standards, honeybee-ph-utils, and honeybee-ph-hvac. All of them need something that imports honeybee-energy to make sure that the import order resolves itself before these packages start doing their thing. It doesn’t necessarily need to be a direct call to honeybee_energy._extend_honeybee and a simple statement like the following should trigger honeybee_energry.__init__.py in order to extend honeybee:

import honeybee_energy

I’m kinda surprised that this has not come up yet for the other honeybee-ph users but maybe there’s something about the way IronPython 2.7 imports the libraries that helps everyone get lucky that they import in the right order. The same luck does not seem to exist on the cPython 3.10 that we use with Ladybug Tools.

In any event, let us know when you make the change, @edmay .

Also, I was going to bring up the workflow for pip installing to the Python we ship with ladybug tools if the error from the installer component was not clear enough. But @edmay 's installer component is basically running pip install using subrpocess so it should be effectively the same as running that workflow from a terminal.

Still getting an error. I tried (before I saw @chriswmackey comment) this:

# -*- coding: utf-8 -*-
# -*- Python Version: 2.7 -*-

"""Package: Honeybee-PH Classes and functions to allow for Passive-House data within Honeybee.

These classes are designed to be used within a Honeybee-editing environment, such as Rhino or 
Grasshopper. These classes will allow for Passive House specific data to be added to certain 
relevant Honeybee entities and logged for later use.
"""

# load all functions that extends honeybee core library
import honeybee_energy._extend_honeybee
import honeybee_ph._extend_honeybee_ph

Testing different solutions will take some time since I have to wait for IT to try anything when changing files in this folder… Any other ideas?

Here is the traceback for your reference:
error.zip (2.3 KB)

You would have to update all 5 of the honeybee_ph packages in order to not get the error anymore, @smarentette . Maybe it’s best to just wait for @edmay to push fixes before you give this a try.

Ah! Thanks for all that info. I will make the update right now.

So the issue is that its trying to load honeybee-ph before honeybee-energy is fully resolved? That makes sense I suppose. Though I agree: its surprising this hasn’t popped up previously? We run honeybee-ph in all sorts of non-IronPython environments and I haven’t run into this before? Curious…

Regardless, I will push this change right now. Do you think the best thing would be add import honeybee_energy to every extension’s root __init__ file? That should trigger the full honeybee_energy plugin load sequence, yes? Or do you think I should include the full _extend_honeybee command within each of my __init__ files?

I initially did a test by just importing honeybee-energy and it didn’t solve the problem. The full version ensures that the libraries get loaded.

Thanks @mostapha

Ok, I think I see the issue here now. You are 100% correct. There are a couple places where importing honeybee_energy withing my honeybee_ph plugin, which is incorrect on my part. I’ll refactor these items properly so that this doesn’t need to happen in the future.

But for now, I have also added the import honeybee_energy._extend_honeybee line first to all of my extension __init__ files. Hopefully this is able to resolve the issue in the short term until I can properly re-work the honeybee_ph modules which are causing this problem.

@smarentette , if you download and run the up to date installer, then copy/paste as you did before (or do the pip install . . . if that is working now following Mostapha’s directions?) then I’m hopeful this might work for you?

Let me know if not, and I can see what else I can do!
@edmay

1 Like

Hi @edmay ,

I just tried running your installer and, while the original error has gone away, I get a new one now:

C:\Program Files\ladybug_tools\python\python -m honeybee_energy lib to-model-properties --include-abridged 
Traceback (most recent call last):
  File "C:\Program Files\ladybug_tools\python\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\ladybug_tools\python\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\ladybug_tools\python\lib\site-packages\honeybee_energy\__main__.py", line 1, in <module>
    from honeybee_energy.cli import energy
  File "C:\Program Files\ladybug_tools\python\lib\site-packages\honeybee_energy\cli\__init__.py", line 17, in <module>
    from .validate import validate
  File "C:\Program Files\ladybug_tools\python\lib\site-packages\honeybee_energy\cli\validate.py", line 18, in <module>
    import honeybee_schema.energy.programtype as schema_programtype
  File "C:\Program Files\ladybug_tools\python\lib\site-packages\honeybee_schema\energy\programtype.py", line 4, in <module>
    from ._base import IDdEnergyBaseModel
  File "C:\Program Files\ladybug_tools\python\lib\site-packages\honeybee_schema\energy\_base.py", line 5, in <module>
    from .._base import NoExtraBaseModel
  File "C:\Program Files\ladybug_tools\python\lib\site-packages\honeybee_schema\_base.py", line 16, in <module>
    class IDdBaseModel(NoExtraBaseModel):
  File "C:\Program Files\ladybug_tools\python\lib\site-packages\honeybee_schema\_base.py", line 19, in IDdBaseModel
    identifier: str = Field(
  File "C:\Program Files\ladybug_tools\python\lib\site-packages\pydantic\fields.py", line 798, in Field
    raise PydanticUserError('`regex` is removed. use `pattern` instead', code='removed-kwargs')
pydantic.errors.PydanticUserError: `regex` is removed. use `pattern` instead

For further information visit https://errors.pydantic.dev/2.7/u/removed-kwargs

It looks like honeybee-ph is using a version of pydantic that is incompatible with the rest of Ladybug Tools, which seems weird to me because I thought honeybee-ph was primarily running in IronPython 2.7 where pydantic can’t be loaded anyway.

Whatever the case, for some reason, your installer is installing Pydantic 2.7.3, @edmay :

But the rest of Ladybug Tools needs a version of Pydantic that is <2.0 as you can see here:

So you will have to change this if you want to be fully compatible with Ladybug Tools.

FYI, I found a workaround for the pydantic incompatibility above. If I just run the LB Versioner after using the honeybee-grasshopper-ph installer script, this will put back the correct version of Pydantic and allow me to use both Ladybug Tools/Pollination as well as honeybee-ph.

Whoops! My mistake. For some reason I did not realize that and don’t get those errors? Weird. But yes: I just pushed the update to >2.0 a few days ago.

We use it for managing all the excel-document (PHPP) schemas, the WUFI-Passive XML file schemas, and all the response models for a web-viewer thing. All those PHX input/output operations use subprocess and the LBT py3.10 interpreter from within Grasshopper for all that work, not IronPython.

Let me look at what I’ll need to do unwind all the updates I made and, I’ll see if I can easily revert back to <2.0. It is really just all the @validator stuff they changed - so I think I should be able to revert back with too much fuss… :crossed_fingers:

@edmay

1 Like

FYI, we should be back to Pydantic <2 now.

@edmay