Difference between revisions of "DESK-XZ7-L-AN-0004: Using Python with BORA"

From DAVE Developer's Wiki
Jump to: navigation, search
(asyncua)
(Python on DESK)
(4 intermediate revisions by the same user not shown)
Line 17: Line 17:
 
| Oct 2022
 
| Oct 2022
 
|DESK-XZ7-L 1.0.0-rc1
 
|DESK-XZ7-L 1.0.0-rc1
|-
 
! 1.0.1
 
! Jan 2024
 
!DESK-XZ7-L 1.0.1
 
 
|-
 
|-
 
|}
 
|}
Line 50: Line 46:
 
</pre>
 
</pre>
  
<code>pip3</code> can be installed using python and the related script [https://pip.pypa.io/en/stable/installation/#get-pip-py <code>get-pip-py</code>]:
+
<code>pip3</code> version can be upgraded too:
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@bora:~# wget https://bootstrap.pypa.io/get-pip.py
+
root@bora:~# pip3 --version
Connecting to bootstrap.pypa.io (151.101.0.175:443)
+
pip 20.0.2 from /usr/lib/python3.8/site-packages/pip (python 3.8)
wget: note: TLS certificate validation not implemented
+
root@bora:~# pip3 install --upgrade pip
saving to 'get-pip.py'
 
get-pip.py          100% |********************************************************************************************| 2573k  0:00:00 ETA
 
'get-pip.py' saved
 
root@bora:~# python3 get-pip.py
 
 
Collecting pip
 
Collecting pip
   Downloading pip-23.3.2-py3-none-any.whl.metadata (3.5 kB)
+
   Downloading pip-22.3-py3-none-any.whl (2.1 MB)
Collecting setuptools
+
    |████████████████████████████████| 2.1 MB 289 kB/s  
  Downloading setuptools-69.0.3-py3-none-any.whl.metadata (6.3 kB)
+
Installing collected packages: pip
Collecting wheel
+
  Attempting uninstall: pip
  Downloading wheel-0.42.0-py3-none-any.whl.metadata (2.2 kB)
+
    Found existing installation: pip 20.0.2
Downloading pip-23.3.2-py3-none-any.whl (2.1 MB)
+
    Uninstalling pip-20.0.2:
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 2.1 MB/s eta 0:00:00
+
      Successfully uninstalled pip-20.0.2
Downloading setuptools-69.0.3-py3-none-any.whl (819 kB)
+
Successfully installed pip-22.3
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 819.5/819.5 kB 1.9 MB/s eta 0:00:00
 
Downloading wheel-0.42.0-py3-none-any.whl (65 kB)
 
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 65.4/65.4 kB 427.3 kB/s eta 0:00:00
 
DEPRECATION: gpg 1.14.0-unknown has a non-standard version number. pip 24.0 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of gpg or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063
 
Installing collected packages: wheel, setuptools, pip
 
Successfully installed pip-23.3.2 setuptools-69.0.3 wheel-0.42.0
 
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
 
 
root@bora:~#  
 
root@bora:~#  
</pre>
 
* then, pip version can be checked
 
<pre class="board-terminal">
 
root@bora:~# pip3 --version
 
pip 23.3.2 from /usr/lib/python3.8/site-packages/pip (python 3.8)
 
root@bora:~#
 
 
</pre>
 
</pre>
  
Line 93: Line 72:
 
root@bora:~# python3 -m pip install --user virtualenv
 
root@bora:~# python3 -m pip install --user virtualenv
 
Collecting virtualenv
 
Collecting virtualenv
   Downloading virtualenv-20.25.0-py3-none-any.whl.metadata (4.5 kB)
+
   Downloading virtualenv-20.16.5-py3-none-any.whl (8.8 MB)
Collecting distlib<1,>=0.3.7 (from virtualenv)
+
    |████████████████████████████████|  8.8/8.8 MB 2.5 MB/s eta 0:00:00
  Downloading distlib-0.3.8-py2.py3-none-any.whl.metadata (5.1 kB)
+
Collecting filelock<4,>=3.4.1
Collecting filelock<4,>=3.12.2 (from virtualenv)
+
   Downloading filelock-3.8.0-py3-none-any.whl (10 kB)
   Downloading filelock-3.13.1-py3-none-any.whl.metadata (2.8 kB)
+
Collecting distlib<1,>=0.3.5
Collecting platformdirs<5,>=3.9.1 (from virtualenv)
+
  Downloading distlib-0.3.6-py2.py3-none-any.whl (468 kB)
  Downloading platformdirs-4.1.0-py3-none-any.whl.metadata (11 kB)
+
    |████████████████████████████████|  468.5/468.5 kB 2.2 MB/s eta 0:00:00
Downloading virtualenv-20.25.0-py3-none-any.whl (3.8 MB)
+
Collecting platformdirs<3,>=2.4
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.8/3.8 MB 1.9 MB/s eta 0:00:00
+
  Downloading platformdirs-2.5.2-py3-none-any.whl (14 kB)
Downloading distlib-0.3.8-py2.py3-none-any.whl (468 kB)
 
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 kB 2.2 MB/s eta 0:00:00
 
Downloading filelock-3.13.1-py3-none-any.whl (11 kB)
 
Downloading platformdirs-4.1.0-py3-none-any.whl (17 kB)
 
DEPRECATION: gpg 1.14.0-unknown has a non-standard version number. pip 24.0 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of gpg or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063
 
 
Installing collected packages: distlib, platformdirs, filelock, virtualenv
 
Installing collected packages: distlib, platformdirs, filelock, virtualenv
 
   WARNING: The script virtualenv is installed in '/home/root/.local/bin' which is not on PATH.
 
   WARNING: The script virtualenv is installed in '/home/root/.local/bin' which is not on PATH.
 
   Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
 
   Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed distlib-0.3.8 filelock-3.13.1 platformdirs-4.1.0 virtualenv-20.25.0
+
Successfully installed distlib-0.3.6 filelock-3.8.0 platformdirs-2.5.2 virtualenv-20.16.5
 
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
 
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@bora:~#
+
root@bora:~#  
 
</pre>
 
</pre>
 
+
then the <code>virtual environment</code> named '''desk''' can be created:
* the <code>virtual environment</code> named '''desk''' can be created:
 
 
<pre class="board-terminal">
 
<pre class="board-terminal">
 
root@bora:~# python3 -m venv desk
 
root@bora:~# python3 -m venv desk
Line 122: Line 95:
 
* activate the <code>virtual environment</code>
 
* activate the <code>virtual environment</code>
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@bora:~# source desk/bin/activate
+
root@bora:~# source env/bin/activate
 
(desk) root@bora:~#  
 
(desk) root@bora:~#  
 
</pre>
 
</pre>
Line 129: Line 102:
 
(desk) root@bora:~# pip3 install --upgrade pip
 
(desk) root@bora:~# pip3 install --upgrade pip
 
Collecting pip
 
Collecting pip
   Downloading pip-23.3.2-py3-none-any.whl (2.1 MB)
+
   Using cached pip-22.3-py3-none-any.whl (2.1 MB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1 MB 167 kB/s
 
 
Installing collected packages: pip
 
Installing collected packages: pip
 
   Attempting uninstall: pip
 
   Attempting uninstall: pip
Line 136: Line 108:
 
     Uninstalling pip-20.1.1:
 
     Uninstalling pip-20.1.1:
 
       Successfully uninstalled pip-20.1.1
 
       Successfully uninstalled pip-20.1.1
Successfully installed pip-23.3.2
+
Successfully installed pip-22.3
 +
(desk) root@bora:~# pip3 --version
 +
pip 22.3 from /home/root/env/lib/python3.8/site-packages/pip (python 3.8)
 
(desk) root@bora:~#
 
(desk) root@bora:~#
 
</pre>
 
</pre>
Line 142: Line 116:
 
<pre class="board-terminal">
 
<pre class="board-terminal">
 
(desk) root@bora:~# pip3 install --upgrade setuptools
 
(desk) root@bora:~# pip3 install --upgrade setuptools
Requirement already satisfied: setuptools in ./desk/lib/python3.8/site-packages (47.1.0)
+
Requirement already satisfied: setuptools in ./env/lib/python3.8/site-packages (47.1.0)
 
Collecting setuptools
 
Collecting setuptools
   Using cached setuptools-69.0.3-py3-none-any.whl.metadata (6.3 kB)
+
   Downloading setuptools-65.5.0-py3-none-any.whl (1.2 MB)
Using cached setuptools-69.0.3-py3-none-any.whl (819 kB)
+
    |████████████████████████████████|  1.2/1.2 MB 2.3 MB/s eta 0:00:00
 
Installing collected packages: setuptools
 
Installing collected packages: setuptools
 
   Attempting uninstall: setuptools
 
   Attempting uninstall: setuptools
Line 151: Line 125:
 
     Uninstalling setuptools-47.1.0:
 
     Uninstalling setuptools-47.1.0:
 
       Successfully uninstalled setuptools-47.1.0
 
       Successfully uninstalled setuptools-47.1.0
Successfully installed setuptools-69.0.3
+
Successfully installed setuptools-65.5.0
(desk) root@bora:~#
+
(desk) root@bora:~#  
 
</pre>
 
</pre>
  
Line 159: Line 133:
 
(desk) root@bora:~# pip3 install wheel
 
(desk) root@bora:~# pip3 install wheel
 
Collecting wheel
 
Collecting wheel
   Using cached wheel-0.42.0-py3-none-any.whl.metadata (2.2 kB)
+
   Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Using cached wheel-0.42.0-py3-none-any.whl (65 kB)
 
 
Installing collected packages: wheel
 
Installing collected packages: wheel
Successfully installed wheel-0.42.0
+
Successfully installed wheel-0.37.1
(desk) root@bora:~#
+
(desk) root@bora:~#  
 
</pre>
 
</pre>
 
== packages installation==
 
== packages installation==
Line 170: Line 143:
 
In this example, the following packages are installed:
 
In this example, the following packages are installed:
 
* '''asyncua''' (OPCUA client and server library)
 
* '''asyncua''' (OPCUA client and server library)
* '''bcrypt''' (password hashing)
 
 
* '''can''' (color animator)
 
* '''can''' (color animator)
 
* '''cbor''' (Concise Binary Object Representation - CBOR is comparable to JSON, has a superset of JSON’s ability)
 
* '''cbor''' (Concise Binary Object Representation - CBOR is comparable to JSON, has a superset of JSON’s ability)
 
* '''netifaces''' (network interface info)
 
* '''netifaces''' (network interface info)
 
* '''ntplib''' (Python NTP)
 
* '''ntplib''' (Python NTP)
 +
* '''paramiko''' (SSH2 protocol library)
 +
* '''psutil''' (process and system monitoring)
 
* '''pymodbus''' (Modbus stack protocol)
 
* '''pymodbus''' (Modbus stack protocol)
* '''pyserial''' (Serial Port extension)
 
 
* '''python-daemon''' (Standard daemon process library)
 
* '''python-daemon''' (Standard daemon process library)
* '''python-dateutil''' (Python extension dateutil)
 
 
* '''python-prctl''' (C extension for system call)
 
* '''python-prctl''' (C extension for system call)
 
* '''requests''' (Python HTTP)
 
* '''requests''' (Python HTTP)
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
(desk) root@bora:~# pip3 install netifaces
 
Collecting netifaces
 
  Using cached netifaces-0.11.0.tar.gz (30 kB)
 
  Preparing metadata (setup.py) ... done
 
Building wheels for collected packages: netifaces
 
  Building wheel for netifaces (setup.py) ... done
 
  Created wheel for netifaces: filename=netifaces-0.11.0-cp38-cp38-linux_armv7l.whl size=35205 sha256=e405dea3379d15e715be65b57f651beef13df5df815013bb8332960a481f58ac
 
  Stored in directory: /home/root/.cache/pip/wheels/04/e2/b4/b811799a082cacaeff801af32c856fbefe6279ba96554d9a21
 
Successfully built netifaces
 
Installing collected packages: netifaces
 
Successfully installed netifaces-0.11.0
 
(desk) root@bora:~# pip3 install can
 
Collecting can
 
  Downloading can-0.0.0.tar.gz (1.0 kB)
 
  Preparing metadata (setup.py) ... done
 
Building wheels for collected packages: can
 
  Building wheel for can (setup.py) ... done
 
  Created wheel for can: filename=can-0.0.0-py3-none-any.whl size=1266 sha256=b210b09ceb4ddf6c322bd2b7b249976cd45312b0919b7044158698ca604d9a00
 
  Stored in directory: /home/root/.cache/pip/wheels/45/b4/e7/1f023b01e25425d5b9f3d2d537af7d7bf632e5d7a66ee703ed
 
Successfully built can
 
Installing collected packages: can
 
Successfully installed can-0.0.0
 
 
(desk) root@bora:~# pip3 install cbor
 
(desk) root@bora:~# pip3 install cbor
 
Collecting cbor
 
Collecting cbor
 
   Downloading cbor-1.0.0.tar.gz (20 kB)
 
   Downloading cbor-1.0.0.tar.gz (20 kB)
   Preparing metadata (setup.py) ... done
+
   Preparing metadata (setup.py) ... - \ done
 
Building wheels for collected packages: cbor
 
Building wheels for collected packages: cbor
   Building wheel for cbor (setup.py) ... done
+
   Building wheel for cbor (setup.py) ... - \ | / - \ | / - done
   Created wheel for cbor: filename=cbor-1.0.0-py3-none-any.whl size=10029 sha256=36179cc461113f665dd3e948c56e5928726b83f01efc6107fe08030bf49ed8b2
+
   Created wheel for cbor: filename=cbor-1.0.0-cp38-cp38-linux_armv7l.whl size=51722 sha256=056a9213e339003ff735d05fec04fa008ce05284211db1bc8c38083efb20013d
   Stored in directory: /home/root/.cache/pip/wheels/31/3a/8a/9d1a5e6f83f620826578089812b8ac236b86eaf4fbc3b36384
+
   Stored in directory: /home/root/.cache/pip/wheels/62/39/af/70e4f2f1154ae74c7689a115210902b4adcf8967f94253f878
 
Successfully built cbor
 
Successfully built cbor
 
Installing collected packages: cbor
 
Installing collected packages: cbor
 
Successfully installed cbor-1.0.0
 
Successfully installed cbor-1.0.0
(desk) root@bora:~# pip3 install requests
 
Collecting requests
 
  Downloading requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
 
Collecting charset-normalizer<4,>=2 (from requests)
 
  Downloading charset_normalizer-3.3.2-py3-none-any.whl.metadata (33 kB)
 
Collecting idna<4,>=2.5 (from requests)
 
  Downloading idna-3.6-py3-none-any.whl.metadata (9.9 kB)
 
Collecting urllib3<3,>=1.21.1 (from requests)
 
  Downloading urllib3-2.1.0-py3-none-any.whl.metadata (6.4 kB)
 
Collecting certifi>=2017.4.17 (from requests)
 
  Downloading certifi-2023.11.17-py3-none-any.whl.metadata (2.2 kB)
 
Downloading requests-2.31.0-py3-none-any.whl (62 kB)
 
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 557.9 kB/s eta 0:00:00
 
Downloading certifi-2023.11.17-py3-none-any.whl (162 kB)
 
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 162.5/162.5 kB 1.2 MB/s eta 0:00:00
 
Downloading charset_normalizer-3.3.2-py3-none-any.whl (48 kB)
 
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.5/48.5 kB 424.1 kB/s eta 0:00:00
 
Downloading idna-3.6-py3-none-any.whl (61 kB)
 
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.6/61.6 kB 542.1 kB/s eta 0:00:00
 
Downloading urllib3-2.1.0-py3-none-any.whl (104 kB)
 
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 104.6/104.6 kB 959.3 kB/s eta 0:00:00
 
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
 
Successfully installed certifi-2023.11.17 charset-normalizer-3.3.2 idna-3.6 requests-2.31.0 urllib3-2.1.0
 
(desk) root@bora:~# pip3 install pymodbus
 
Collecting pymodbus
 
  Downloading pymodbus-3.6.3-py3-none-any.whl.metadata (14 kB)
 
Downloading pymodbus-3.6.3-py3-none-any.whl (205 kB)
 
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 205.2/205.2 kB 1.1 MB/s eta 0:00:00
 
Installing collected packages: pymodbus
 
Successfully installed pymodbus-3.6.3
 
(desk) root@bora:~# pip3 install ntplib
 
Collecting ntplib
 
  Downloading ntplib-0.4.0-py2.py3-none-any.whl (6.8 kB)
 
Installing collected packages: ntplib
 
Successfully installed ntplib-0.4.0
 
(desk) root@bora:~# pip3 install python-daemon
 
Collecting python-daemon
 
  Downloading python_daemon-3.0.1-py3-none-any.whl (31 kB)
 
Collecting docutils (from python-daemon)
 
  Downloading docutils-0.20.1-py3-none-any.whl.metadata (2.8 kB)
 
Collecting lockfile>=0.10 (from python-daemon)
 
  Downloading lockfile-0.12.2-py2.py3-none-any.whl (13 kB)
 
Requirement already satisfied: setuptools>=62.4.0 in ./desk/lib/python3.8/site-packages (from python-daemon) (69.0.3)
 
Downloading docutils-0.20.1-py3-none-any.whl (572 kB)
 
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 572.7/572.7 kB 452.5 kB/s eta 0:00:00
 
Installing collected packages: lockfile, docutils, python-daemon
 
Successfully installed docutils-0.20.1 lockfile-0.12.2 python-daemon-3.0.1
 
(desk) root@bora:~# pip3 install python-dateutil
 
Collecting python-dateutil
 
  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
 
Collecting six>=1.5 (from python-dateutil)
 
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
 
Installing collected packages: six, python-dateutil
 
Successfully installed python-dateutil-2.8.2 six-1.16.0
 
 
(desk) root@bora:~# pip3 install python-prctl
 
(desk) root@bora:~# pip3 install python-prctl
 
Collecting python-prctl
 
Collecting python-prctl
   Using cached python-prctl-1.8.1.tar.gz (28 kB)
+
   Downloading python-prctl-1.8.1.tar.gz (28 kB)
   Preparing metadata (setup.py) ... done
+
   Preparing metadata (setup.py) ... - \ done
 
Building wheels for collected packages: python-prctl
 
Building wheels for collected packages: python-prctl
   Building wheel for python-prctl (setup.py) ... done
+
   Building wheel for python-prctl (setup.py) ... - \ | / - \ | done
   Created wheel for python-prctl: filename=python_prctl-1.8.1-cp38-cp38-linux_armv7l.whl size=25369 sha256=369d991812ce1d758297332ae01c9d725f0bd5bc480c382bf8b4a917a5ebd6c0
+
   Created wheel for python-prctl: filename=python_prctl-1.8.1-cp38-cp38-linux_armv7l.whl size=25341 sha256=c117e57bb506c338071debe433cc8f9ce559400a7f4c6d68fca9aea33812a5d1
   Stored in directory: /home/root/.cache/pip/wheels/70/90/f1/b786edccb1b2d9290281dad80c8aa0e93ab5c1f845a8d404aa
+
   Stored in directory: /home/root/.cache/pip/wheels/d2/28/a0/76bcff726d677b487a8c926f51f4e672380ff8ca78c7d8d619
 
Successfully built python-prctl
 
Successfully built python-prctl
 
Installing collected packages: python-prctl
 
Installing collected packages: python-prctl
 
Successfully installed python-prctl-1.8.1
 
Successfully installed python-prctl-1.8.1
(desk) root@bora:~# pip3 install pyserial
+
(desk) root@bora:~# pip3 install netifaces
Collecting pyserial
+
Collecting netifaces
   Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB)
+
   Downloading netifaces-0.11.0.tar.gz (30 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 90.6/90.6 kB 86.5 kB/s eta 0:00:00
+
  Preparing metadata (setup.py) ... - \ done
Installing collected packages: pyserial
+
Building wheels for collected packages: netifaces
Successfully installed pyserial-3.5
+
  Building wheel for netifaces (setup.py) ... - \ | / - \ | / - \ | / - \ | / - done
 +
  Created wheel for netifaces: filename=netifaces-0.11.0-cp38-cp38-linux_armv7l.whl size=35204 sha256=e49fb06ca220a45c58c3c7df3c311eebd8968fd13e8a45038ad82620a3365b7a
 +
  Stored in directory: /home/root/.cache/pip/wheels/f1/2a/15/7d0abf7b60244bd5d7b32699837118eac09cb3f9f305164a71
 +
Successfully built netifaces
 +
Installing collected packages: netifaces
 +
Successfully installed netifaces-0.11.0
 +
(desk) root@bora:~# pip3 install psutil
 +
Collecting psutil
 +
  Downloading psutil-5.9.3.tar.gz (483 kB)
 +
    |████████████████████████████████|  483.6/483.6 kB 2.3 MB/s eta 0:00:00
 +
  Installing build dependencies ... - \ | done
 +
  Getting requirements to build wheel ... - \ | done
 +
  Installing backend dependencies ... - \ | done
 +
  Preparing metadata (pyproject.toml) ... - \ | / done
 +
Building wheels for collected packages: psutil
 +
  Building wheel for psutil (pyproject.toml) ... - \ | / - \ | / - \ | / - \ | / done
 +
  Created wheel for psutil: filename=psutil-5.9.3-cp38-cp38-linux_armv7l.whl size=289747 sha256=95645d458a09ba46fff0a52d5957947310afc52520588259038f75ab2cb60012
 +
  Stored in directory: /home/root/.cache/pip/wheels/8d/fc/1f/072e3caf8d3a4d56c497287c7741ad4c483d4adc65c9109abe
 +
Successfully built psutil
 +
Installing collected packages: psutil
 +
Successfully installed psutil-5.9.3
 +
(desk) root@bora:~# pip3 install requests
 +
Collecting requests
 +
  Downloading requests-2.28.1-py3-none-any.whl (62 kB)
 +
     |████████████████████████████████|  62.8/62.8 kB 887.7 kB/s eta 0:00:00
 +
Collecting idna<4,>=2.5
 +
  Downloading idna-3.4-py3-none-any.whl (61 kB)
 +
    |████████████████████████████████|  61.5/61.5 kB 830.4 kB/s eta 0:00:00
 +
Collecting certifi>=2017.4.17
 +
  Downloading certifi-2022.9.24-py3-none-any.whl (161 kB)
 +
    |████████████████████████████████|  161.1/161.1 kB 1.2 MB/s eta 0:00:00
 +
Collecting charset-normalizer<3,>=2
 +
  Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
 +
Collecting urllib3<1.27,>=1.21.1
 +
  Downloading urllib3-1.26.12-py2.py3-none-any.whl (140 kB)
 +
    |████████████████████████████████|  140.4/140.4 kB 2.1 MB/s eta 0:00:00
 +
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
 +
Successfully installed certifi-2022.9.24 charset-normalizer-2.1.1 idna-3.4 requests-2.28.1 urllib3-1.26.12
 
(desk) root@bora:~#  
 
(desk) root@bora:~#  
 
</pre>
 
</pre>
Line 298: Line 231:
 
* execute the installer script:
 
* execute the installer script:
 
<pre>
 
<pre>
./rustup-init.sh
+
root@bora:~# ./rustup-init.sh
 +
info: downloading installer
 +
Warning: using the BusyBox version of wget.  Not enforcing strong cipher suites for TLS or TLS v1.2, this is potentially less secure
 +
Connecting to static.rust-lang.org (99.86.159.71:443)
 +
wget: note: TLS certificate validation not implemented
 +
saving to '/tmp/tmp.crML5188Vt/rustup-init'
 +
rustup-init          100% |********************************| 13.5M  0:00:00 ETA
 +
'/tmp/tmp.crML5188Vt/rustup-init' saved
 +
$<2>
 +
Welcome to Rust!
 +
$<2>
 +
This will download and install the official compiler for the Rust
 +
programming language, and its package manager, Cargo.
 +
...
 +
...
 +
 
 +
$<2>
 +
Rust is installed now. Great!
 +
$<2>
 +
To get started you may need to restart your current shell.
 +
This would reload your $<2>PATH$<2> environment variable to include
 +
Cargo's bin directory ($HOME/.cargo/bin).
 +
 
 +
To configure your current shell, run:
 +
source "$HOME/.cargo/env"
 
root@bora:~#  
 
root@bora:~#  
 
</pre>
 
</pre>
 
Once installed the related environment should be initialized:
 
Once installed the related environment should be initialized:
 
<pre class="board-terminal">
 
<pre class="board-terminal">
(desk) root@bora:~# source "$HOME/.cargo/env"
+
root@bora:~# source "$HOME/.cargo/env"
 +
root@bora:~#
 
</pre>
 
</pre>
For building <code>wheel</code> some package are required (like <code>python3-dev</code>) and this can be installed using <code>dnf</code>:
+
and again the ''Virtual environment'' activated (for installing the package inside the env):
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@bora:~# dnf install python3-dev
+
root@bora:~# source env/bin/activate
OE Remote Repo: sswreleases rel-v2021.2 generic 1.4 kB/s | 257  B    00:00
+
root@bora:~#
OE Remote Repo: sswreleases rel-v2021.2 generic 3.7 kB/s | 257  B    00:00
+
</pre>
OE Remote Repo: sswreleases rel-v2021.2 generic 1.2 MB/s | 139 kB    00:00
 
OE Remote Repo: sswreleases rel-v2021.2 generic 4.7 kB/s | 257  B    00:00
 
OE Remote Repo: sswreleases rel-v2021.2 generic 4.3 kB/s | 257  B    00:00
 
...
 
Dependencies resolved.
 
================================================================================
 
Package              Architecture      Version      Repository          Size
 
================================================================================
 
Installing:
 
python3-dev          cortexa9t2hf_neon 3.8.5-r0.0    oe-remote-repo-sswreleases-rel-v2021.2-generic-rpm-cortexa9t2hf_neon
 
  
...
 
...
 
Transaction Summary
 
================================================================================
 
Install  80 Packages
 
 
Total download size: 3.7 M
 
Installed size: 19 M
 
Is this ok [y/N]: y
 
Downloading Packages:
 
...
 
...
 
root@bora:~#
 
</pre>
 
 
In this way, the <code>asyncua</code> package can be built/installed:
 
In this way, the <code>asyncua</code> package can be built/installed:
 
<pre class="board-terminal">
 
<pre class="board-terminal">
(desk) root@bora:~# pip3 install asyncua
+
(desk) root@bora:~# python3 -m pip install asyncua
 
Collecting asyncua
 
Collecting asyncua
   Using cached asyncua-1.0.6-py3-none-any.whl.metadata (9.3 kB)
+
   Downloading asyncua-1.0.0-py3-none-any.whl (747 kB)
Collecting aiofiles (from asyncua)
+
    |████████████████████████████████| 747.6/747.6 kB 2.4 MB/s eta 0:00:00
   Using cached aiofiles-23.2.1-py3-none-any.whl.metadata (9.7 kB)
+
Collecting cryptography
Collecting aiosqlite (from asyncua)
+
  Downloading cryptography-38.0.1.tar.gz (599 kB)
   Using cached aiosqlite-0.19.0-py3-none-any.whl (15 kB)
+
    |████████████████████████████████| 599.4/599.4 kB 2.2 MB/s eta 0:00:00
Requirement already satisfied: python-dateutil in ./desk/lib/python3.8/site-packages (from asyncua) (2.8.2)
+
   Installing build dependencies ... - \ | / - \ | / - \ | / - \ | / done
Collecting pytz (from asyncua)
+
  Getting requirements to build wheel ... - \ | / done
   Using cached pytz-2023.4-py2.py3-none-any.whl.metadata (22 kB)
+
  Preparing metadata (pyproject.toml) ... - \ | / - done
Collecting cryptography>40.0.1 (from asyncua)
+
Collecting pytz
   Downloading cryptography-42.0.2.tar.gz (672 kB)
+
   Downloading pytz-2022.5-py2.py3-none-any.whl (500 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 672.8/672.8 kB 559.1 kB/s eta 0:00:00
+
    |████████████████████████████████| 500.7/500.7 kB 2.3 MB/s eta 0:00:00
  Installing build dependencies ... done
+
Collecting aiosqlite
  Getting requirements to build wheel ... done
+
   Downloading aiosqlite-0.17.0-py3-none-any.whl (15 kB)
  Preparing metadata (pyproject.toml) ... done
+
Collecting python-dateutil
Collecting sortedcontainers (from asyncua)
+
   Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
 +
     |████████████████████████████████| 247.7/247.7 kB 940.5 kB/s eta 0:00:00
 +
Collecting sortedcontainers
 
   Downloading sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
 
   Downloading sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
Collecting pyOpenSSL (from asyncua)
+
Collecting aiofiles
   Downloading pyOpenSSL-24.0.0-py3-none-any.whl.metadata (12 kB)
+
   Downloading aiofiles-22.1.0-py3-none-any.whl (14 kB)
Collecting typing-extensions (from asyncua)
+
Collecting typing_extensions>=3.7.2
   Downloading typing_extensions-4.9.0-py3-none-any.whl.metadata (3.0 kB)
+
   Using cached typing_extensions-4.4.0-py3-none-any.whl (26 kB)
Collecting cffi>=1.12 (from cryptography>40.0.1->asyncua)
+
Collecting cffi>=1.12
   Using cached cffi-1.16.0-cp38-cp38-linux_armv7l.whl
+
   Using cached cffi-1.15.1-cp38-cp38-linux_armv7l.whl
Requirement already satisfied: six>=1.5 in ./desk/lib/python3.8/site-packages (from python-dateutil->asyncua) (1.16.0)
+
Collecting six>=1.5
Collecting pycparser (from cffi>=1.12->cryptography>40.0.1->asyncua)
+
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
 +
Collecting pycparser
 
   Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
 
   Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Downloading asyncua-1.0.6-py3-none-any.whl (773 kB)
 
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 773.0/773.0 kB 2.2 MB/s eta 0:00:00
 
Downloading aiofiles-23.2.1-py3-none-any.whl (15 kB)
 
Downloading pyOpenSSL-24.0.0-py3-none-any.whl (58 kB)
 
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.6/58.6 kB 521.5 kB/s eta 0:00:00
 
Downloading pytz-2023.4-py2.py3-none-any.whl (506 kB)
 
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 506.5/506.5 kB 480.3 kB/s eta 0:00:00
 
Downloading typing_extensions-4.9.0-py3-none-any.whl (32 kB)
 
 
Building wheels for collected packages: cryptography
 
Building wheels for collected packages: cryptography
   Building wheel for cryptography (pyproject.toml) ... done
+
   Building wheel for cryptography (pyproject.toml) ... | / - \ done
   Created wheel for cryptography: filename=cryptography-42.0.2-cp38-cp38-linux_armv7l.whl size=2206468 sha256=27ef627b5636e640bc179ff1ad13948ac029ad3c709d1e137670f6c5fe79c131
+
   Created wheel for cryptography: filename=cryptography-38.0.1-cp38-cp38-linux_armv7l.whl size=1768831 sha256=1cfd149510ee62605549bde5a24cb6bbd2f959094906ec6d22c4850fd2b6268d
   Stored in directory: /home/root/.cache/pip/wheels/b8/2d/51/9a40e9f8548e174065e9988ad0eece7edf49ece9b2251e0790
+
   Stored in directory: /home/root/.cache/pip/wheels/fb/dd/30/687c60465a7b76d3b461f7eb89da28d4f68edc182d625a3ccf
 
Successfully built cryptography
 
Successfully built cryptography
Installing collected packages: sortedcontainers, pytz, typing-extensions, pycparser, aiosqlite, aiofiles, cffi, cryptography, pyOpenSSL, asyncua
+
Installing collected packages: sortedcontainers, pytz, typing_extensions, six, pycparser, aiofiles, python-dateutil, cffi, aiosqlite, cryptography, asyncua
Successfully installed aiofiles-23.2.1 aiosqlite-0.19.0 asyncua-1.0.6 cffi-1.16.0 cryptography-42.0.2 pyOpenSSL-24.0.0 pycparser-2.21 pytz-2023.4 sortedcontainers-2.4.0 typing-extensions-4.9.0
+
Successfully installed aiofiles-22.1.0 aiosqlite-0.17.0 asyncua-1.0.0 cffi-1.15.1 cryptography-38.0.1 pycparser-2.21 python-dateutil-2.8.2 pytz-2022.5 six-1.16.0 sortedcontainers-2.4.0 typing_extensions-4.4.0
(desk) root@bora:~#
+
(desk) root@bora:~#
 +
</pre>
 +
=== paramiko ===
 +
Some package may have some troubles too about the versioning of sub-package. For example, this is the case where <code>paramiko</code> cannot be installed due to some build errors, see [https://github.com/paramiko/paramiko/issues/1761 Paramiko error while building pynacl].
 +
 
 +
This issue can be overcome installing a previous version for <code>PyNaCl</code>:
 +
 
 +
It occurs only with PyNaCl==1.5.0, so you can specify PyNaCl==1.4.0. It's OK because paramiko's requirement is PyNacl>=1.0.1
 +
 
 +
For example, the version '''1.2.0''' can be succesfully installed:
 +
<pre class="board-terminal">
 +
(desk) root@bora:~# pip3 install PyNaCl==1.2.0
 +
Collecting PyNaCl==1.2.0
 +
  Downloading PyNaCl-1.2.0.tar.gz (3.3 MB)
 +
    |████████████████████████████████| 3.3/3.3 MB 2.4 MB/s eta 0:00:00
 +
  Preparing metadata (setup.py) ... done
 +
Requirement already satisfied: six in ./env/lib/python3.8/site-packages (from PyNaCl==1.2.0) (1.16.0)
 +
Requirement already satisfied: cffi>=1.4.1 in ./env/lib/python3.8/site-packages (from PyNaCl==1.2.0) (1.15.1)
 +
Requirement already satisfied: pycparser in ./env/lib/python3.8/site-packages (from cffi>=1.4.1->PyNaCl==1.2.0) (2.21)
 +
Building wheels for collected packages: PyNaCl
 +
  Building wheel for PyNaCl (setup.py) ... done
 +
  Created wheel for PyNaCl: filename=PyNaCl-1.2.0-cp38-cp38-linux_armv7l.whl size=465695 sha256=b9d81dd6c93cd1b1527683500d2e6efbefaef1fadeddff5bef799cbba5d6dd47
 +
  Stored in directory: /home/root/.cache/pip/wheels/c8/a7/4c/f03548f24ea252a853b28a9281ac3d3bb59107432fa5cd0a4e
 +
Successfully built PyNaCl
 +
Installing collected packages: PyNaCl
 +
Successfully installed PyNaCl-1.2.0
 +
(desk) root@bora:~#
 +
</pre>
 +
and the [https://pypi.org/project/paramiko/ paramiko] module is then installed:
 +
<pre class="board-terminal">
 +
(desk) root@bora:~# pip3 install paramiko
 +
Collecting paramiko
 +
  Downloading paramiko-2.11.0-py2.py3-none-any.whl (212 kB)
 +
    |████████████████████████████████| 212.9/212.9 kB 1.5 MB/s eta 0:00:00
 +
Collecting bcrypt>=3.1.3
 +
  Downloading bcrypt-4.0.1.tar.gz (25 kB)
 +
  Installing build dependencies ... done
 +
  Getting requirements to build wheel ... done
 +
  Preparing metadata (pyproject.toml) ... done
 +
Requirement already satisfied: six in ./env/lib/python3.8/site-packages (from paramiko) (1.16.0)
 +
Requirement already satisfied: pynacl>=1.0.1 in ./env/lib/python3.8/site-packages (from paramiko) (1.2.0)
 +
Requirement already satisfied: cryptography>=2.5 in ./env/lib/python3.8/site-packages (from paramiko) (38.0.1)
 +
Requirement already satisfied: cffi>=1.12 in ./env/lib/python3.8/site-packages (from cryptography>=2.5->paramiko) (1.15.1)
 +
Requirement already satisfied: pycparser in ./env/lib/python3.8/site-packages (from cffi>=1.12->cryptography>=2.5->paramiko) (2.21)
 +
Building wheels for collected packages: bcrypt
 +
  Building wheel for bcrypt (pyproject.toml) ... done
 +
  Created wheel for bcrypt: filename=bcrypt-4.0.1-cp38-cp38-linux_armv7l.whl size=597512 sha256=cc3884972a18b64377fab94c738fc4f2abf0c78ca4d6cb1eec41848fde710078
 +
  Stored in directory: /home/root/.cache/pip/wheels/5c/32/05/1f093a4b4e1de66f1cff0a05ef844adbe89dcc027163712ee4
 +
Successfully built bcrypt
 +
Installing collected packages: bcrypt, paramiko
 +
Successfully installed bcrypt-4.0.1 paramiko-2.11.0
 +
(desk) root@bora:~#  
 
</pre>
 
</pre>
  
Line 387: Line 367:
 
(desk) root@bora:~# pip3 list
 
(desk) root@bora:~# pip3 list
 
Package            Version
 
Package            Version
------------------ ----------
+
------------------ ---------
(desk) root@bora:~#
+
aiofiles          22.1.0
aiofiles          23.2.1
+
aiosqlite          0.17.0
aiosqlite          0.19.0
+
asyncua            1.0.0
asyncua            1.0.6
+
bcrypt            4.0.1
bcrypt            4.1.2
 
 
can                0.0.0
 
can                0.0.0
 
cbor              1.0.0
 
cbor              1.0.0
certifi            2023.11.17
+
certifi            2022.9.24
cffi              1.16.0
+
cffi              1.15.1
charset-normalizer 3.3.2
+
charset-normalizer 2.1.1
cryptography      42.0.2
+
cryptography      38.0.1
docutils          0.20.1
+
docutils          0.19
idna              3.6
+
idna              3.4
 
lockfile          0.12.2
 
lockfile          0.12.2
 
netifaces          0.11.0
 
netifaces          0.11.0
 
ntplib            0.4.0
 
ntplib            0.4.0
pip                23.3.2
+
paramiko          2.11.0
 +
pip                22.3
 +
psutil            5.9.3
 
pycparser          2.21
 
pycparser          2.21
pymodbus          3.6.3
+
pymodbus          3.0.0
 
PyNaCl            1.2.0
 
PyNaCl            1.2.0
pyOpenSSL          24.0.0
+
python-daemon      2.3.2
pyserial          3.5
 
python-daemon      3.0.1
 
 
python-dateutil    2.8.2
 
python-dateutil    2.8.2
 
python-prctl      1.8.1
 
python-prctl      1.8.1
pytz              2023.4
+
pytz              2022.5
requests          2.31.0
+
requests          2.28.1
setuptools        69.0.3
+
setuptools        65.5.0
 
six                1.16.0
 
six                1.16.0
 
sortedcontainers  2.4.0
 
sortedcontainers  2.4.0
typing_extensions  4.9.0
+
typing_extensions  4.4.0
urllib3            2.1.0
+
urllib3            1.26.12
wheel              0.42.0
+
wheel              0.37.1
(desk) root@bora:~#  
+
(desk) root@bora:~#
 
</pre>
 
</pre>
  
Line 435: Line 414:
 
>>> import cbor
 
>>> import cbor
 
>>> import daemon
 
>>> import daemon
>>> import dateutil
 
 
>>> import netifaces
 
>>> import netifaces
 
>>> import ntplib
 
>>> import ntplib
 +
>>> import paramiko
 +
>>> import psutil
 
>>> import pymodbus
 
>>> import pymodbus
 
>>> import prctl
 
>>> import prctl
>>> import serial
 
 
>>> import requests
 
>>> import requests
 
>>>
 
>>>
 
</pre>
 
</pre>

Revision as of 14:28, 12 December 2023

Info Box


200px-Emblem-important.svg.png

This application note has been validated using the kit version in the History table.

History[edit | edit source]

Version Date Development Kit version

1.0.0

Oct 2022 DESK-XZ7-L 1.0.0-rc1

Introduction[edit | edit source]

As found on Python official website, Python is a programming language that lets you work more quickly and integrate your systems more effectively and also Python can be easy to pick up whether you're a first-time programmer or you're experienced with other languages.

These sentences got a real confirmation if you have a look at the IEEE Top Programming Languages 2021 ranking. As you can see in the following picture Python reached the Top of the ranking even more than the native C language used since the beginning in Embedded systems programming:


IEEE Top programming languages 2021 - Embedded


As reported in this article The C/C++ programming languages dominate embedded systems programming, though they have a number of disadvantages. Python, on the other hand, has many strengths that make it a great language for embedded systems.

This application note provides some examples of software packages installation that can be used for building a Python development system adding python3 libraries to the BORA platform.

Python on DESK[edit | edit source]

python3 application is already present on DESK-XZ7-L petalinux root file system.

Installing python packages[edit | edit source]

First of all check for the default installed python/pip version in the DESK-XZ7 root file system:

root@bora:~# python3 --version
Python 3.8.5
root@bora:~#

pip3 version can be upgraded too:

root@bora:~# pip3 --version
pip 20.0.2 from /usr/lib/python3.8/site-packages/pip (python 3.8)
root@bora:~# pip3 install --upgrade pip
Collecting pip
  Downloading pip-22.3-py3-none-any.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 289 kB/s 
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Uninstalling pip-20.0.2:
      Successfully uninstalled pip-20.0.2
Successfully installed pip-22.3
root@bora:~# 

Virtual environments[edit | edit source]

As explained on python3 12. Virtual Environments and Packages tutorial it is better to "create a virtual environment, a self-contained directory tree that contains a Python installation for a particular version of Python, plus a number of additional packages"

This avoids the problem related to Applications that sometimes need a specific version of a library. In this way, it is possible to install the required packages (with their specific version required) only in this virtual environment (which may differ from the root installation).

First of all the venv module should be installed:

root@bora:~# python3 -m pip install --user virtualenv
Collecting virtualenv
  Downloading virtualenv-20.16.5-py3-none-any.whl (8.8 MB)
     |████████████████████████████████|  8.8/8.8 MB 2.5 MB/s eta 0:00:00
Collecting filelock<4,>=3.4.1
  Downloading filelock-3.8.0-py3-none-any.whl (10 kB)
Collecting distlib<1,>=0.3.5
  Downloading distlib-0.3.6-py2.py3-none-any.whl (468 kB)
     |████████████████████████████████|  468.5/468.5 kB 2.2 MB/s eta 0:00:00
Collecting platformdirs<3,>=2.4
  Downloading platformdirs-2.5.2-py3-none-any.whl (14 kB)
Installing collected packages: distlib, platformdirs, filelock, virtualenv
  WARNING: The script virtualenv is installed in '/home/root/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed distlib-0.3.6 filelock-3.8.0 platformdirs-2.5.2 virtualenv-20.16.5
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@bora:~# 

then the virtual environment named desk can be created:

root@bora:~# python3 -m venv desk
root@bora:~# 
  • activate the virtual environment
root@bora:~# source env/bin/activate
(desk) root@bora:~# 
  • upgrade pip3 in the virtual environment:
(desk) root@bora:~# pip3 install --upgrade pip
Collecting pip
  Using cached pip-22.3-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.1.1
    Uninstalling pip-20.1.1:
      Successfully uninstalled pip-20.1.1
Successfully installed pip-22.3
(desk) root@bora:~# pip3 --version
pip 22.3 from /home/root/env/lib/python3.8/site-packages/pip (python 3.8)
(desk) root@bora:~#
  • setuptools can be upgraded too:
(desk) root@bora:~# pip3 install --upgrade setuptools
Requirement already satisfied: setuptools in ./env/lib/python3.8/site-packages (47.1.0)
Collecting setuptools
  Downloading setuptools-65.5.0-py3-none-any.whl (1.2 MB)
     |████████████████████████████████|  1.2/1.2 MB 2.3 MB/s eta 0:00:00
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 47.1.0
    Uninstalling setuptools-47.1.0:
      Successfully uninstalled setuptools-47.1.0
Successfully installed setuptools-65.5.0
(desk) root@bora:~# 

Afterword, the wheel package is worth to be installed for further package installation:

(desk) root@bora:~# pip3 install wheel
Collecting wheel
  Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.37.1
(desk) root@bora:~# 

packages installation[edit | edit source]

For the purposes of this Application Note, pip3 has been used to install some python packages typically used in a controller equipment.

In this example, the following packages are installed:

  • asyncua (OPCUA client and server library)
  • can (color animator)
  • cbor (Concise Binary Object Representation - CBOR is comparable to JSON, has a superset of JSON’s ability)
  • netifaces (network interface info)
  • ntplib (Python NTP)
  • paramiko (SSH2 protocol library)
  • psutil (process and system monitoring)
  • pymodbus (Modbus stack protocol)
  • python-daemon (Standard daemon process library)
  • python-prctl (C extension for system call)
  • requests (Python HTTP)
(desk) root@bora:~# pip3 install cbor
Collecting cbor
  Downloading cbor-1.0.0.tar.gz (20 kB)
  Preparing metadata (setup.py) ... - \ done
Building wheels for collected packages: cbor
  Building wheel for cbor (setup.py) ... - \ | / - \ | / - done
  Created wheel for cbor: filename=cbor-1.0.0-cp38-cp38-linux_armv7l.whl size=51722 sha256=056a9213e339003ff735d05fec04fa008ce05284211db1bc8c38083efb20013d
  Stored in directory: /home/root/.cache/pip/wheels/62/39/af/70e4f2f1154ae74c7689a115210902b4adcf8967f94253f878
Successfully built cbor
Installing collected packages: cbor
Successfully installed cbor-1.0.0
(desk) root@bora:~# pip3 install python-prctl
Collecting python-prctl
  Downloading python-prctl-1.8.1.tar.gz (28 kB)
  Preparing metadata (setup.py) ... - \ done
Building wheels for collected packages: python-prctl
  Building wheel for python-prctl (setup.py) ... - \ | / - \ | done
  Created wheel for python-prctl: filename=python_prctl-1.8.1-cp38-cp38-linux_armv7l.whl size=25341 sha256=c117e57bb506c338071debe433cc8f9ce559400a7f4c6d68fca9aea33812a5d1
  Stored in directory: /home/root/.cache/pip/wheels/d2/28/a0/76bcff726d677b487a8c926f51f4e672380ff8ca78c7d8d619
Successfully built python-prctl
Installing collected packages: python-prctl
Successfully installed python-prctl-1.8.1
(desk) root@bora:~# pip3 install netifaces
Collecting netifaces
  Downloading netifaces-0.11.0.tar.gz (30 kB)
  Preparing metadata (setup.py) ... - \ done
Building wheels for collected packages: netifaces
  Building wheel for netifaces (setup.py) ... - \ | / - \ | / - \ | / - \ | / - done
  Created wheel for netifaces: filename=netifaces-0.11.0-cp38-cp38-linux_armv7l.whl size=35204 sha256=e49fb06ca220a45c58c3c7df3c311eebd8968fd13e8a45038ad82620a3365b7a
  Stored in directory: /home/root/.cache/pip/wheels/f1/2a/15/7d0abf7b60244bd5d7b32699837118eac09cb3f9f305164a71
Successfully built netifaces
Installing collected packages: netifaces
Successfully installed netifaces-0.11.0
(desk) root@bora:~# pip3 install psutil
Collecting psutil
  Downloading psutil-5.9.3.tar.gz (483 kB)
     |████████████████████████████████|  483.6/483.6 kB 2.3 MB/s eta 0:00:00
  Installing build dependencies ... - \ | done
  Getting requirements to build wheel ... - \ | done
  Installing backend dependencies ... - \ | done
  Preparing metadata (pyproject.toml) ... - \ | / done
Building wheels for collected packages: psutil
  Building wheel for psutil (pyproject.toml) ... - \ | / - \ | / - \ | / - \ | / done
  Created wheel for psutil: filename=psutil-5.9.3-cp38-cp38-linux_armv7l.whl size=289747 sha256=95645d458a09ba46fff0a52d5957947310afc52520588259038f75ab2cb60012
  Stored in directory: /home/root/.cache/pip/wheels/8d/fc/1f/072e3caf8d3a4d56c497287c7741ad4c483d4adc65c9109abe
Successfully built psutil
Installing collected packages: psutil
Successfully installed psutil-5.9.3
(desk) root@bora:~# pip3 install requests
Collecting requests
  Downloading requests-2.28.1-py3-none-any.whl (62 kB)
     |████████████████████████████████|  62.8/62.8 kB 887.7 kB/s eta 0:00:00
Collecting idna<4,>=2.5
  Downloading idna-3.4-py3-none-any.whl (61 kB)
     |████████████████████████████████|  61.5/61.5 kB 830.4 kB/s eta 0:00:00
Collecting certifi>=2017.4.17
  Downloading certifi-2022.9.24-py3-none-any.whl (161 kB)
     |████████████████████████████████|  161.1/161.1 kB 1.2 MB/s eta 0:00:00
Collecting charset-normalizer<3,>=2
  Downloading charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.12-py2.py3-none-any.whl (140 kB)
     |████████████████████████████████|  140.4/140.4 kB 2.1 MB/s eta 0:00:00
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
Successfully installed certifi-2022.9.24 charset-normalizer-2.1.1 idna-3.4 requests-2.28.1 urllib3-1.26.12
(desk) root@bora:~# 

asyncua[edit | edit source]

Some packages may require Rust compiler for building the (for example) wheel:

  • download the rust Linux installer
wget https://sh.rustup.rs
  • execute the installer script:
root@bora:~# ./rustup-init.sh
info: downloading installer
Warning: using the BusyBox version of wget.  Not enforcing strong cipher suites for TLS or TLS v1.2, this is potentially less secure
Connecting to static.rust-lang.org (99.86.159.71:443)
wget: note: TLS certificate validation not implemented
saving to '/tmp/tmp.crML5188Vt/rustup-init'
rustup-init          100% |********************************| 13.5M  0:00:00 ETA
'/tmp/tmp.crML5188Vt/rustup-init' saved
$<2>
Welcome to Rust!
$<2>
This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.
...
...

$<2>
Rust is installed now. Great!
$<2>
To get started you may need to restart your current shell.
This would reload your $<2>PATH$<2> environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source "$HOME/.cargo/env"
root@bora:~# 

Once installed the related environment should be initialized:

root@bora:~# source "$HOME/.cargo/env"
root@bora:~# 

and again the Virtual environment activated (for installing the package inside the env):

root@bora:~# source env/bin/activate
root@bora:~# 

In this way, the asyncua package can be built/installed:

(desk) root@bora:~# python3 -m pip install asyncua
Collecting asyncua
  Downloading asyncua-1.0.0-py3-none-any.whl (747 kB)
     |████████████████████████████████| 747.6/747.6 kB 2.4 MB/s eta 0:00:00
Collecting cryptography
  Downloading cryptography-38.0.1.tar.gz (599 kB)
     |████████████████████████████████| 599.4/599.4 kB 2.2 MB/s eta 0:00:00
  Installing build dependencies ... - \ | / - \ | / - \ | / - \ | / done
  Getting requirements to build wheel ... - \ | / done
  Preparing metadata (pyproject.toml) ... - \ | / - done
Collecting pytz
  Downloading pytz-2022.5-py2.py3-none-any.whl (500 kB)
     |████████████████████████████████| 500.7/500.7 kB 2.3 MB/s eta 0:00:00
Collecting aiosqlite
  Downloading aiosqlite-0.17.0-py3-none-any.whl (15 kB)
Collecting python-dateutil
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     |████████████████████████████████| 247.7/247.7 kB 940.5 kB/s eta 0:00:00
Collecting sortedcontainers
  Downloading sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
Collecting aiofiles
  Downloading aiofiles-22.1.0-py3-none-any.whl (14 kB)
Collecting typing_extensions>=3.7.2
  Using cached typing_extensions-4.4.0-py3-none-any.whl (26 kB)
Collecting cffi>=1.12
  Using cached cffi-1.15.1-cp38-cp38-linux_armv7l.whl
Collecting six>=1.5
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting pycparser
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Building wheels for collected packages: cryptography
  Building wheel for cryptography (pyproject.toml) ... | / - \ done
  Created wheel for cryptography: filename=cryptography-38.0.1-cp38-cp38-linux_armv7l.whl size=1768831 sha256=1cfd149510ee62605549bde5a24cb6bbd2f959094906ec6d22c4850fd2b6268d
  Stored in directory: /home/root/.cache/pip/wheels/fb/dd/30/687c60465a7b76d3b461f7eb89da28d4f68edc182d625a3ccf
Successfully built cryptography
Installing collected packages: sortedcontainers, pytz, typing_extensions, six, pycparser, aiofiles, python-dateutil, cffi, aiosqlite, cryptography, asyncua
Successfully installed aiofiles-22.1.0 aiosqlite-0.17.0 asyncua-1.0.0 cffi-1.15.1 cryptography-38.0.1 pycparser-2.21 python-dateutil-2.8.2 pytz-2022.5 six-1.16.0 sortedcontainers-2.4.0 typing_extensions-4.4.0
(desk) root@bora:~# 

paramiko[edit | edit source]

Some package may have some troubles too about the versioning of sub-package. For example, this is the case where paramiko cannot be installed due to some build errors, see Paramiko error while building pynacl.

This issue can be overcome installing a previous version for PyNaCl:

It occurs only with PyNaCl==1.5.0, so you can specify PyNaCl==1.4.0. It's OK because paramiko's requirement is PyNacl>=1.0.1

For example, the version 1.2.0 can be succesfully installed:

(desk) root@bora:~# pip3 install PyNaCl==1.2.0
Collecting PyNaCl==1.2.0
  Downloading PyNaCl-1.2.0.tar.gz (3.3 MB)
     |████████████████████████████████| 3.3/3.3 MB 2.4 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Requirement already satisfied: six in ./env/lib/python3.8/site-packages (from PyNaCl==1.2.0) (1.16.0)
Requirement already satisfied: cffi>=1.4.1 in ./env/lib/python3.8/site-packages (from PyNaCl==1.2.0) (1.15.1)
Requirement already satisfied: pycparser in ./env/lib/python3.8/site-packages (from cffi>=1.4.1->PyNaCl==1.2.0) (2.21)
Building wheels for collected packages: PyNaCl
  Building wheel for PyNaCl (setup.py) ... done
  Created wheel for PyNaCl: filename=PyNaCl-1.2.0-cp38-cp38-linux_armv7l.whl size=465695 sha256=b9d81dd6c93cd1b1527683500d2e6efbefaef1fadeddff5bef799cbba5d6dd47
  Stored in directory: /home/root/.cache/pip/wheels/c8/a7/4c/f03548f24ea252a853b28a9281ac3d3bb59107432fa5cd0a4e
Successfully built PyNaCl
Installing collected packages: PyNaCl
Successfully installed PyNaCl-1.2.0
(desk) root@bora:~# 

and the paramiko module is then installed:

(desk) root@bora:~# pip3 install paramiko
Collecting paramiko
  Downloading paramiko-2.11.0-py2.py3-none-any.whl (212 kB)
     |████████████████████████████████| 212.9/212.9 kB 1.5 MB/s eta 0:00:00
Collecting bcrypt>=3.1.3
  Downloading bcrypt-4.0.1.tar.gz (25 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: six in ./env/lib/python3.8/site-packages (from paramiko) (1.16.0)
Requirement already satisfied: pynacl>=1.0.1 in ./env/lib/python3.8/site-packages (from paramiko) (1.2.0)
Requirement already satisfied: cryptography>=2.5 in ./env/lib/python3.8/site-packages (from paramiko) (38.0.1)
Requirement already satisfied: cffi>=1.12 in ./env/lib/python3.8/site-packages (from cryptography>=2.5->paramiko) (1.15.1)
Requirement already satisfied: pycparser in ./env/lib/python3.8/site-packages (from cffi>=1.12->cryptography>=2.5->paramiko) (2.21)
Building wheels for collected packages: bcrypt
  Building wheel for bcrypt (pyproject.toml) ... done
  Created wheel for bcrypt: filename=bcrypt-4.0.1-cp38-cp38-linux_armv7l.whl size=597512 sha256=cc3884972a18b64377fab94c738fc4f2abf0c78ca4d6cb1eec41848fde710078
  Stored in directory: /home/root/.cache/pip/wheels/5c/32/05/1f093a4b4e1de66f1cff0a05ef844adbe89dcc027163712ee4
Successfully built bcrypt
Installing collected packages: bcrypt, paramiko
Successfully installed bcrypt-4.0.1 paramiko-2.11.0
(desk) root@bora:~# 

check for installed packages and version[edit | edit source]

At the end, the package installed can be listed:

(desk) root@bora:~# pip3 list
Package            Version
------------------ ---------
aiofiles           22.1.0
aiosqlite          0.17.0
asyncua            1.0.0
bcrypt             4.0.1
can                0.0.0
cbor               1.0.0
certifi            2022.9.24
cffi               1.15.1
charset-normalizer 2.1.1
cryptography       38.0.1
docutils           0.19
idna               3.4
lockfile           0.12.2
netifaces          0.11.0
ntplib             0.4.0
paramiko           2.11.0
pip                22.3
psutil             5.9.3
pycparser          2.21
pymodbus           3.0.0
PyNaCl             1.2.0
python-daemon      2.3.2
python-dateutil    2.8.2
python-prctl       1.8.1
pytz               2022.5
requests           2.28.1
setuptools         65.5.0
six                1.16.0
sortedcontainers   2.4.0
typing_extensions  4.4.0
urllib3            1.26.12
wheel              0.37.1
(desk) root@bora:~#

package import[edit | edit source]

The installed packages can be imported and used:

(env) root@bora:~# python3
Python 3.8.5 (default, Jul 20 2020, 13:26:22)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncua
>>> import can
>>> import cbor
>>> import daemon
>>> import netifaces
>>> import ntplib
>>> import paramiko
>>> import psutil
>>> import pymodbus
>>> import prctl
>>> import requests
>>>