在 Win10 上安裝測試 PyTorch 後, 初步覺得 PyTorch 真的好用, 跟 Keras 一樣簡潔但彈性更大, 所以就想在樹莓派上也安裝看看. 我在 PyPi 上找到一個樹莓派用的 v0.4.0 版 whl 檔 :
# https://pypi.org/project/torch-raspi/
在 Download 頁面複製下載連結, 用 wget 指令下載安裝卻出現 "not a supported wheel on this platform" 訊息 :
pi@raspberrypi:~ $ wget https://files.pythonhosted.org/packages/94/2e/45178cbf729f96d961c97a940fd1780f8054a740fa959cf7555e8434e0fd/rpi3.torch-0.1.0-cp35-cp35m-linux_armv7l.whl
--2018-12-30 08:29:08-- https://files.pythonhosted.org/packages/94/2e/45178cbf729f96d961c97a940fd1780f8054a740fa959cf7555e8434e0fd/rpi3.torch-0.1.0-cp35-cp35m-linux_armv7l.whl
Resolving files.pythonhosted.org (files.pythonhosted.org)... 151.101.73.63, 2a04:4e42:36::319
Connecting to files.pythonhosted.org (files.pythonhosted.org)|151.101.73.63|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 52261275 (50M) [binary/octet-stream]
Saving to: ‘rpi3.torch-0.1.0-cp35-cp35m-linux_armv7l.whl’
rpi3.torch-0.1.0-cp 100%[=====================>] 49.84M 247KB/s in 91s
2018-12-30 08:30:41 (563 KB/s) - ‘rpi3.torch-0.1.0-cp35-cp35m-linux_armv7l.whl’ saved [52261275/52261275]
pi@raspberrypi:~ $ pip3 install rpi3.torch-0.1.0-cp35-cp35m-linux_armv7l.whl
rpi3.torch-0.1.0-cp35-cp35m-linux_armv7l.whl is not a supported wheel on this platform.
由於此 whl 檔標明是使用 Python 3.5 編譯, 我懷疑是不是因為我的 Pi 3 上的舊 Raspbian 系統為 v3.4.2 版之故, 所以想另外安裝 Python 3.5 試試看 :
pi@raspberrypi:~ $ python3
Python 3.4.2 (default, Oct 19 2014, 13:31:11)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
我找到下面這篇安裝 Python 3.6 的文章, 按其程序來安裝 3.5 版. 在 Python 官網的 ftp 站可找到各版本的 Python 源碼, Python 3.5 最後一個更新是 Python 3.5.6, 我下載的源碼是 Python-3.5.6.tar.xz :
- wget https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tar.xz
- tar xf Python-3.5.6.tar.xz
- cd Python-3.5.6
- ./configure
- make
- sudo make altinstall
完畢後執行 python3.5 就會進入 IDLE 介面 :
pi@raspberrypi:~ $ python3.5
Python 3.5.6 (default, Dec 30 2018, 13:58:11)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
可用 whereis 或 which 指令查詢 python3.5 安裝位置 :
pi@raspberrypi:~ $ whereis python3.5
python3: /usr/bin/python3.4 /usr/bin/python3.4m /usr/bin/python3.4-config /usr/bin/python3.4m-config /usr/bin/python3 /usr/lib/python3.4 /usr/lib/python3 /etc/python3.4 /etc/python3 /usr/local/bin/python3.5 /usr/local/bin/python3.5m /usr/local/bin/python3.5m-config /usr/local/lib/python3.5 /usr/local/lib/python3.4 /usr/include/python3.4 /usr/include/python3.4m /usr/share/python3 /usr/share/man/man1/python3.1.gz
pi@raspberrypi:~ $ which python
/usr/bin/python (Python 2)
pi@raspberrypi:~ $ which python3.5
/usr/local/bin/python3.5 (Python 3.5)
pi@raspberrypi:~ $ which python3
/usr/bin/python3 (Python 3.4.2)
可見目前這塊 Pi 3 SD 卡內已經有三種 Python 版本了, 但是用 pip3 安裝那個 whl 檔還是不行, 查詢 pip3 還是跑 Python 3.4.2 版的, 如果是這個造成的要怎麼改?
pi@raspberrypi:~ $ sudo pip3 install rpi3.torch-0.1.0-cp35-cp35m-linux_armv7l.whl
rpi3.torch-0.1.0-cp35-cp35m-linux_armv7l.whl is not a supported wheel on this platform.
pi@raspberrypi:~ $ which pip3
/usr/local/bin/pip3
pi@raspberrypi:~ $ pip3 --version
pip 18.1 from /usr/local/lib/python3.4/dist-packages/pip (python 3.4)
pi@raspberrypi:~ $ pip3 --version
pip 18.1 from /usr/local/lib/python3.4/dist-packages/pip (python 3.4)
沒有留言:
張貼留言