Problem Virtualenv to install Google Home Assistan on Openwrt

Hi. I want to create a virtualenv to install and run Google Home Assistant on Xiaomi Mir3g running Pandorabox( Based on Openwrt 18.06) without buy a new Raspberry Pi

I found a article For LEDGE here: https://lingbo.me/2018/04/07/在lede软路由上运行home-assistant/
so i run:
opkg update
opkg install python3 python3-pip
pip3 install virtualenv
Everything is OK, but when i want create python 3.6 virtual environment by command:

virtualenv /mnt/sda1/hass -p /usr/bin/python3.6

It shows error:
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /mnt/sda1/hass/bin/python3
Fatal Python error: Py_Initialize: Unable to get the locale encoding
Traceback (most recent call last):
File "/init.py", line 33, in
ImportError: cannot import name 'aliases'
ERROR: The executable /mnt/sda1/hass/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/mnt/sda1' (should be '/mnt/sda1/hass')
ERROR: virtualenv is not compatible with this system or executable

So I can't create Python 3.6 Virtual Env. I still can create Virtualenv with python 2.7 but Google Home Assisitant will not run on it( It require Python 3.5 or later).
Hopefully everyone can help. Thanks.

1 Like

Python 2 itself is EOL, so using Python 3 is a good idea.

https://docs.python.org/3/library/venv.html

https://docs.python.org/3/tutorial/venv.html

1 Like

I suggest you simply install your needed python packages into the main python environment, instead of trying to create a venv/virutalenv.

My guess is that ability to create and use a venv/virutalenv is not considered important enough for most openwrt use cases, compared to keeping the value of keeping the size of the OS and its libraries small. venv/virutalenv seems to require locale settings, and that is not even installed on openwrt, and from what I understand requires custom compilation.

1 Like

tks you. I have successfully create virtual env but homeassisitant require too many python libs to load. So, I give up. thank you!

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.