因爲在新版的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