How to use the honeybee python API

Hello! I am learning how to use the Python API for honeybee. I have installed the pip install honeybee-core and have ensured honeybee is in the correct virtual environment… it is listed in the installed packages. But when I type import honeybee I keep getting errors. How can I start creating a honeybee room directly in python? What is the first thing I should be typing?

Thanks for your help! Attaching relevant screenshot.
image

Hello @elenialex ,

It appears that you are doing it right. Based on your screenshot it appears you are using VSCode (?) - so I would guess that it is just an issue of VSCode needing to know which python interpreter to use (where the honeybee-core package is installed).

In VSCode, when you create a virtual-environment in a project folder, you often need to set the interpreter explicitly by clicking on the button in the lower right:

once you select the right interpreter (in your case, the one in your virtual environment) then your paths should resolve properly within the IDE:

The next time you open the project in VSCode, it should remember which interpreter to use, so once you set it once you shouldn’t need to do it again. If you are still having trouble with it, I have found that sometimes rebooting VSCode a time or two also helps it to recognize the virtual-environment properly.

Note also that it seems to me that VSCode really likes it if your virtual env is named ‘venv’ or ‘.venv’ - to keep things easy, I would recommend sticking with that convention if you can.

best of luck,
@edpmay

2 Likes

Thank you @edpmay ! It was indeed an issue with the interpreter.