Using remote api when homeassistant is installed in virtual environment

Hello,

I have installed homeassistant an an rpi3 in virtual environment.

I try to use the Python Remote Api to get the states of some sensors in my python script.
I created the script with idle3 as user pi.

My python script starts with the next command:
import homeassistant.remote as remote

I get the following error:
ImportError: No module named ‘homeassistant’

What am i doing wrong?

Thanks in advance.

In my docker version of homeassistant I found that the homeassistant directory wasn’t added to the python imports directory list so I added it manually at the start of my script using sys.path

Thanks for your reply. It sounds logical.

My current pah is:
[’/home/pi’, ‘/usr/bin’, ‘/usr/lib/python35.zip’, ‘/usr/lib/python3.5’, ‘/usr/lib/python3.5/plat-arm-linux-gnueabihf’, ‘/usr/lib/python3.5/lib-dynload’, ‘/usr/local/lib/python3.5/dist-packages’, ‘/usr/lib/python3/dist-packages’]

My virtual environment is located here:
/srv/homeassistant/homeassistant_venv

I tried to add this directory and also some subdirectories to the path but nothing worked so far.

Which directory did you add?

When i also install homeassistant under the user pi the error is gone.
But i don’t want to make every upgrade twice, so i don’t want this situation.

I figured it out.

I had to add this directory:
sys.path.append(’/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages’)

problem solved.