因为在新版的homeassistant当中须要使用python3.5.3及之后的版本,但因为apt源中只包含3.5.2的版本,因此须要升级到python3.6。python
具体更换方式:git
sudo add-apt-repository ppa:jonathonf/python-3.6 sudo apt-get update sudo apt-get install python3.6 python3.6-venv python3.6-dev
具体可参考:https://github.com/home-assistant/home-assistant/issues/13089github
安装Python3.6的pip【2】:sql
curl https://bootstrap.pypa.io/get-pip.py | sudo -H python3.6
具体可参考:https://github.com/home-assistant/home-assistant/issues/13089bootstrap
关于更换到国内镜像:vim
pip install pip -U pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
具体可参考:https://mirror.tuna.tsinghua.edu.cn/help/pypi/curl
更换默认python版本:post
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2 sudo update-alternatives --config python3
具体可参考:https://blog.csdn.net/s_lisheng/article/details/78296177ui
首先,安装相关依赖url
sudo apt install gcc make zlib* libffi-dev libsqlite3-dev libssl-dev openssl
wget --no-check-certificate https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
tar zxvf Python-3.7.3.tgz
cd Python-3.7.3 ./configure --prefix=/usr/local/python3.7
make && sudo make install
sudo ln -s /usr/local/python3.7/bin/python3.7 /usr/bin/python3.7
sudo ln -s /usr/local/python3.7/bin/pip3.7 /usr/bin/pip3
具体的安装过程可参考:https://juejin.im/post/5a74a2515188257a814ce254
cd /home/pi/Desktop && python3 -m venv homeassistant cd homeassistant source bin/activate python3 -m pip install wheel python3 -m pip install homeassistant hass --open-ui
1.建立 home-assistant.service
,并放入如下内容 sudo vim /etc/systemd/system/home-assistant.service
[Unit] Description=Home Assistant After=network.target [Service] Type=simple User=pi Environment=PATH="$VIRTUAL_ENV/bin:$PATH" ExecStart=/home/pi/Desktop/homeassistant/bin/hass -c "/home/pi/.homeassistant" [Install] WantedBy=multi-user.target
2.更新系统设置
sudo systemctl --system daemon-reload
3.设置HomeAssistant开机启动
sudo systemctl enable home-assistant.service
4.启动
sudo systemctl start home-assistant.service
常见错误资料:
Fix ‘E: Could not get lock /var/lib/dpkg/lock’ Error in Ubuntu [Quick Tip]
缺乏ffi.h sudo apt-get install libffi-dev