No module named 'hailo' in Python 3.11 virtual environment despite HailoRT being installed

Hi everyone,

I’m trying to run a Python script that uses import hailo, but I keep getting this error:
ModuleNotFoundError: No module named hailo

I’m using Python 3.11.11 and created a virtual environment like this:

python3.11 -m venv --system-site-packages venv_hailo

I installed HailoRT (version 4.19.0), and it works fine from the command line. When I run: hailortcli fw-control identify
I get:
Executing on device: 0000:01:00.0
Identifying board
Control Protocol Version: 2
Firmware Version: 4.19.0 (release,app,extended context switch buffer)
Logger Version: 0
Board Name: Hailo-8
Device Architecture: HAILO8L

I thought using --system-site-packages when creating the virtual environment would include the hailo module, but Python still doesn’t find it when I try to import it

What am I missing? How can I make ‘import hailo’ work in my virtual environment?

Thanks!

Hey @thomas38,

Let’s try to troubleshoot the issue step by step. Please follow these instructions:

  1. Exit your virtual environment (if currently active) by running:

    deactivate
    
  2. Run the following commands outside the virtual environment:

    python
    import hailo
    
    • If you encounter an error at the import hailo step, it means the hailopython installation was interrupted or not installed correctly. In this case, please reinstall hailopython outside the virtual environment.
    • If the import hailo command succeeds without any errors, proceed to the next step.
  3. If the import hailo command worked outside the virtual environment, re-create the virtual environment using the following command:

    python3.11 -m venv --system-site-packages venv_hailo
    

    Then, activate the virtual environment:

    source venv_hailo/bin/activate
    

    Try running your Python script with import hailo again inside the virtual environment.

  4. If you still face issues, check your PYTHONPATH to ensure it points to the correct directories:

    echo $PYTHONPATH
    

    If necessary, add your virtual environment’s site-packages directory to the PYTHONPATH:

    export PYTHONPATH=venv_hailo/lib/python3.11/site-packages:$PYTHONPATH
    
  5. If none of the above steps resolve the issue, please provide a log or a screenshot of the errors you are encountering. This will help us better understand the problem.

It’s important to note that the hailortcli fw-control command is related to HailoRT, not specifically to hailopython. The fact that hailortcli fw-control works correctly indicates that HailoRT is installed and functioning properly. However, the issue seems to be with the hailopython package itself or its integration with your virtual environment.

Please let me know the results of each step, and if you need further assistance, don’t hesitate to provide more details about the errors you’re seeing.

Best regards,
omria

Hi Omria,

Thanks for your answer

I wanted to update you on the situation. I realized that I had previously installed pyenv on my system. After uninstalling it import hailo worked as expected in my virtual environment

I think the problem was that hailo couldn’t be installed correctly in the virtual environment because pyenv was somehow interfering with the Python environment being used

Thanks again for your help
Best regards,
Thomas