Open main menu

DAVE Developer's Wiki β

Changes

DESK-XZ7-L-AN-0004: Using Python with BORA

660 bytes added, 13:57, 25 October 2022
no edit summary
!Development Kit version
|-
| {{oldid|1478217112|1.0.0}}
| Oct 2022
|DESK-XZ7-L 1.0.0-rc1
== Installing python packages ==
First of all check for the default installed <code>python/pip </code> version in the DESK-XZ7 root file system:
<pre class="board-terminal">
(desk) root@bora:~#
</pre>
* upgrade ''pip3'' in the the <code>virtual environmentpip3</code>in the ''virtual environment'':
<pre class="board-terminal">
(desk) root@bora:~# pip3 install --upgrade pip
</pre>
== packages installation==
For the purposes of this Application Note, <code>pip3</code> 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)
In this example, the following packages are installed '''asyncua''' (OPCUA client and server library), '''pymodbus''' (Modbus stack protocol), '''can''' (color animator), '''cbor''' (RFC7049), '''netifaces''' (network interface info), '''ntplib''' (Python NTP), '''paramiko''' (SSH2 protocol library), '''python-prctl''' (C extension for system call), '''psutil''' (process and system monitoring), '''python-daemon''' (Standard daemon process library), '''requests''' (Python HTTP):
<pre class="board-terminal">
(desk) root@bora:~# pip3 install cbor
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:
(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
wheel 0.37.1
(desk) root@bora:~#
</pre>
 
== package import ==
The installed packages can be imported and used:
<pre class="board-terminal">
(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
>>>
</pre>
8,286
edits