Open main menu

DAVE Developer's Wiki β

Changes

DESK-MX6UL-AN-0004: Using Python for Embedded applications

5,915 bytes added, 09:14, 10 January 2023
no edit summary
{{InfoBoxTop}}
{{AppliesToAXEL ULite AN}}
{{AppliesTo_SBC_Lynx_AN}}
{{AppliesTo_RIALTO_SBC_AN}}
{{InfoBoxBottom}}
{{ImportantMessage|text=This application note has been validated using the '''kit version''' in the History table.}}
!Development Kit version
|-
| {{oldid|14782| 1.0.0}}
| Oct 2021
|{{oldid|14780|DESK-MX6UL-L 1.0.1}}|-| 2.0.0| Apr 2022|[[DESK-MX6UL-L/General/Release_Notes#DESK-MX6UL-L_1L_3.0.10|DESK-MX6UL-L 13.0.10]]
|-
|}
As reported in [https://opensource.com/life/16/8/python-vs-cc-embedded-systems 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 an '''Industrial IoT Gateway''' adding <code>python3</code> libraries to the [[SBC_Lynx_SBC | SBC Lynx]] platform.
== Python on DESK ==
<code>python</code> and <code>python3</code> applications are application is already present on [[DESK-MX6UL-L/Development/Building_the_Yocto_BSP#Quick_reference | DESK-MX6UL-L]] <code>dave-image-devel</code> root file system. Moreover, a huge list of ''python'' packages can be installed in the target using the [https://en.wikipedia.org/wiki/DNF_(software) DNF] package manager: the [[DESK-MX6UL-AN-0003:_Package_Management_with_Yocto_and_DNF | DESK-MX6UL-AN-0003]] shows how to install ''rpm'' packages in the target from the [http://yocto.dave.eu/desk-mx6ul-l-1.0.1/ DAVE's Yocto repository server].
== Installing python packages ==
<pre class="board-terminal">
root@desk-mx6ul-axelulitelynx:~# python3 --versionPython 3.5.5root@desk-mx6ul-axelulite:~# pip --versionpip 9.0.3 from /usr/lib/python2.7/site-packages (python 2.7)4root@desk-mx6ul-axelulitelynx:~#
</pre>
This shows that <code>pip3</code> is not present in the - ''by default'' - on standard root file system and should , but can be easily installed: the simpler way is using python3 itself and the provided python script [https://bootstrap.pypa.io/pip/3.5/get-pip.py get-pip.py] for version 3.5:
<pre class="board-terminal">
root@desk-mx6ul-axelulitelynx:~# python3 curl https://bootstrap.pypa.io/get-pip.pyDEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. -o get-pip 21.py % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 will drop support for Python 3.5 in January 2021. :00:01 --:--:-- 1846kroot@desk-mx6ul-lynx:~# python3 get-pip 21.0 will remove support for this functionality.py Collecting pip<21.0 Downloading pip-2021.3.41-py2.py3-none-any.whl (1.5 7 MB) |#####################| 1.7 MB 2.1 MB/s Collecting setuptools Downloading setuptools-60.5.0-py3-none-any.whl (958 kB) |###########| 958 kB 2.1.5 MB 176 kB/s
Collecting wheel
Downloading wheel-0.37.01-py2.py3-none-any.whl (35 kB)Installing collected packages: wheel, setuptools, pipSuccessfully installed pip-2021.3.4 1 setuptools-60.5.0 wheel-0.37.01WARNING: Running pip as the 'root@desk-mx6ul-axelulite' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https:~# //pippip pip2 pip2.7 pip3 pip3pypa.5io/warnings/venvroot@desk-mx6ul-axelulitelynx:~#
</pre>
After the installation, <code>pip3</code> is the latest version available for '''Python3 3.59.54''':
<pre class="board-terminal">
root@desk-mx6ul-axelulitelynx:~# pip3 --versionpip 2021.3.4 1 from /usr/lib/python3.59/site-packages/pip (python 3.59)root@desk-mx6ul-axelulite:~# easy3_install --versionsetuptools 39.0.0 from /usr/lib/python3.5/site-packages (Python 3.5)root@desk-mx6ul-axelulitelynx:~#
</pre>
=== easy install=Virtual environments ==Even if <code>easy_install</code> tool As explained on [https://setuptoolsdocs.pypapython.io/enorg/latest3/deprecatedtutorial/easy_installvenv.html has been deprecatedpython3 12. Virtual Environments and Packages], tutorial it is better to ''"create a useful tool still present in the typical python distributions.virtual environment, a self-contained directory tree that contains a Python installation for a particular version of Python, plus a number of additional packages"''
For This avoids the purposes problem related to Applications that sometimes need a specific version of a library. In this Application Note, the tool has been used way it is possible to install some python packages typically used in an Industrial Gateway equipment In this example, the following required packages are installed using <code>easy3_install</code> (''easy_install'' with their specific version for python3required): only in this ''virtual environment'pyserial'(which may differ from the '' and root'''pymodbus''' (for bus communicationsinstallation), '''[https://docs.python-requests.org/en/latest/ requests]''' (HTTP library), '''schema''', '''ssdp''':
* for example, create the <code>virtual environment</code> named '''desk'''
<pre class="board-terminal">
root@desk-mx6ul-lynx:~# python3 -m venv desk-env
root@desk-mx6ul-lynx:~# which pip3
/usr/bin/pip3
root@desk-mx6ul-lynx:~#
</pre>
* activate the <code>virtual environment</code>
<pre class="board-terminal">
root@desk-mx6ul-lynx:~# source desk-env/bin/activate
</pre>
* check and update ''pip3'' in the the <code>virtual environment</code>
<pre class="board-terminal">
(desk-env) root@desk-mx6ul-axelulitelynx:~# easy3_install pyserialSearching for pyserialwhich pip3Reading https:/home/pypi.python.orgroot/simpledesk-env/pyserialbin/pip3Downloading https(desk-env) root@desk-mx6ul-lynx://files~# python3 -m pip install --upgrade pipCollecting pip Using cached pip-21.pythonhosted.org/packages/07/bc/587a445451b253b285629263eb51c2d8e9bcea4fc97826266d186f96f558/pyserial-3.51-py2.py3-none-any.whl#sha256=c4451db6ba391ca6ca299fb3ec7bae67a5c55dde170964c7a14ceefec02f2cf0(1.7 MB)Installing collected packages: pip Attempting uninstall: pipBest match Found existing installation: pyserial pip 20.2.3.5Processing pyserial Uninstalling pip-20.2.3.5: Successfully uninstalled pip-py220.py3-none-any2.whl3Installing pyserialSuccessfully installed pip-21.3.51(desk-env) root@desk-mx6ul-py2.py3lynx:~# pip3 -none-anyversionpip 21.3.whl to 1 from /usrhome/libroot/python3.5/sitedesk-packageswriting requirements to /usrenv/lib/python3.59/site-packages/pyserial-pip (python 3.59)(desk-py3.5.egg/EGGenv) root@desk-INFO/requires.txtAdding pyserial 3.5 to easymx6ul-install.pth filelynx:~# Installing pyserial-miniterm script to </usr/binInstalling pyserial-ports script to /usr/binpre>
Installed * <code>setuptools</usr/lib/python3.5/site-packages/pyserial-3.5-py3.5.eggProcessing dependencies for pyserialFinished processing dependencies for pyserialroot@desk-mx6ul-axelulite:~# easy3_install pymodbusSearching for pymodbusReading https://pypi.python.org/simple/pymodbus/Downloading https://files.pythonhosted.org/packages/57/21/6c9b1cade55161444450bdde6e953edb819d984beafee8d4baefa4f0310c/pymodbus-2.5.3rc1-py2.py3-none-any.whl#sha256=e8cbf3594a8dd0f71c287e24d8365e69836c8d22cac5ab288110638fd2b9fda6Best matchcode> can be upgraded too: pymodbus 2.5.3rc1Processing pymodbus-2.5.3rc1-py2.py3-none-any.whlInstalling pymodbus-2.5.3rc1-py2.py3-none-any.whl to /usr/lib/python3.5/site-packageswriting requirements to /usr/lib/python3.5/site-packages/pymodbus-2.5.3rc1-py3.5.egg/EGG-INFO/requires.txtAdding pymodbus 2.5.3rc1 to easy-install.pth fileInstalling pymodbus.console script to /usr/binInstalling pymodbus.server script to /usr/bin
Installed /usr/lib/python3.5/site-packages/pymodbus-2.5.3rc1<pre class="board-py3.5.eggProcessing dependencies for pymodbusSearching for sixterminal">=1.15.0Reading https://pypi.python.org/simple/six/Downloading https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl#sha256=8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254Best match: six 1.16.0Processing six-1.16.0-py2.py3-none-any.whlInstalling six-1.16.0(desk-py2.py3-none-any.whl to /usr/lib/python3.5/site-packagesAdding six 1.16.0 to easy-install.pth file Installed /usr/lib/python3.5/site-packages/six-1.16.0-py3.5.eggFinished processing dependencies for pymodbusenv) root@desk-mx6ul-axelulitelynx:~# easy3_install requestsSearching for requestsReading https://pypi.python.org/simple/requests/Downloading https://files.pythonhosted.org/packages/92/96/144f70b972a9c0eabbd4391ef93ccd49d0f2747f4f6a2a2738e99e5adc65/requestspip3 install -2.26.0-py2.py3-none-any.whl#sha256=6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24upgrade setuptoolsBest matchRequirement already satisfied: requests 2setuptools in .26.0Processing requests-2.26.0-py2.py3-none-any.whlInstalling requests-2.26.0-py2.py3-none-any.whl to /usr/lib/python3.5/sitedesk-packageswriting requirements to /usrenv/lib/python3.59/site-packages/requests-2.26.0-py3.5.egg/EGG-INFO/requires(49.txtAdding requests 2.26.0 to easy-install.pth file1)Collecting setuptoolsInstalled /usr/lib/python3 Using cached setuptools-60.5/site-packages/requests-2.26.0-py3.5.eggProcessing dependencies for requestsSearching for urllib3<1.27,>=1.21.1Reading https://pypi.python.org/simple/urllib3/Downloading https://files.pythonhosted.org/packages/af/f4/524415c0744552cce7d8bf3669af78e8a069514405ea4fcbd0cc44733744/urllib3-1.26.7-py2.py3-none-any.whl#sha256=c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844Best match: urllib3 1.26.7Processing urllib3-1.26.7-py2.py3-none-any.whl(958 kB)Installing urllib3-1.26.7-py2.py3-none-any.whl to /usr/lib/python3.5/site-packageswriting requirements to /usr/lib/python3.5/site-packages/urllib3-1.26.7-py3.5.egg/EGG-INFO/requires.txtAdding urllib3 1.26.7 to easy-install.pth file Installed /usr/lib/python3.5/site-collected packages/urllib3-1.26.7-py3.5.eggSearching for idna<4,>=2.5Reading https://pypi.python.org/simple/idna/setuptoolsDownloading https Attempting uninstall://files.pythonhosted.org/packages/d7/77/ff688d1504cdc4db2a938e2b7b9adee5dd52e34efbd2431051efc9984de9/idna-3.2-py3-none-any.whl#sha256=14475042e284991034cb48e06f6851428fb14c4dc953acd9be9a5e95c7b6dd7asetuptoolsBest match Found existing installation: idna 3setuptools 49.2Processing idna-3.2-py3-none-any.whl1Installing idna Uninstalling setuptools-349.2-py3-none-any.whl to /usr/lib/python3.5/site-packages1:Adding idna 3.2 to easy Successfully uninstalled setuptools-install.pth file Installed /usr/lib/python3.5/site-packages/idna-349.2-py3.5.egg1Searching WARNING: Value for charset-normalizer~=2scheme.0platlib does not match.0Reading https://pypi.python.org/simple/charset-normalizer/Downloading Please report this to <https://filesgithub.pythonhosted.orgcom/packagespypa/3fpip/65issues/69e6754102dcd018a0f29e4db673372eb323ee504431125ab6c9109cb21c/charset_normalizer-2.0.6-py3-none-any.whl#sha256=5d209c0a931f215cee683b6445e2d77677e7e75e159f78def0db09d68fafcaa610151>Best match distutils: charset-normalizer 2.0.6Processing charset_normalizer-2.0.6-py3-none-any.whlInstalling charset_normalizer-2.0.6-py3-none-any.whl to /usrhome/libroot/python3.5/sitedesk-packageswriting requirements to /usrenv/lib/python3.59/site-packages/charset_normalizer-2.0.6-py3.5.egg/EGG-INFO/requires.txtAdding charset-normalizer 2.0.6 to easy-install.pth fileInstalling normalizer script to /usr/bin Installed sysconfig: /usr/lib/python3.59/site-packages/charset_normalizer-2.0.6-py3.5.eggSearching WARNING: Value for certifi>=2017.4.17Reading https://pypi.python.org/simple/certifi/Downloading https://filesscheme.pythonhosted.org/packages/05/1b/0a0dece0e8aa492a6ec9e4ad2fe366b511558cdc73fd3abc82ba7348e875/certifi-2021.5.30-py2.py3-none-any.whl#sha256=50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8Best purelib does not match: certifi 2021.5.30Processing certifi-2021.5.30-py2.py3-none-any.whlInstalling certifi-2021.5.30-py2.py3-none-any.whl Please report this to /usr/lib/python3.5/site-packagesAdding certifi 2021.5.30 to easy-install.pth file Installed /usr/lib/python3.5/site-packages/certifi-2021.5.30-py3.5.eggFinished processing dependencies for requestsroot@desk-mx6ul-axelulite:~# easy3_install schemaSearching for schemaReading <https://pypigithub.python.orgcom/simplepypa/schemapip/Downloading https:issues//files.pythonhosted.org/packages/c7/64/497632c9dc3c1bc94a92d9cafdc5cbd21d011bb651952765195739129a49/schema-0.7.4-py2.py3-none-any.whl#sha256=cf97e4cd27e203ab6bb35968532de1ed8991bce542a646f0ff1d643629a4945d10151>Best match distutils: schema 0.7.4Processing schema-0.7.4-py2.py3-none-any.whlInstalling schema-0.7.4-py2.py3-none-any.whl to /usrhome/libroot/python3.5/sitedesk-packageswriting requirements to /usrenv/lib/python3.59/site-packages/schema-0.7.4-py3.5.egg/EGG-INFO/requires.txtAdding schema 0.7.4 to easy-install.pth file Installed sysconfig: /usr/lib/python3.59/site-packages/schema-0.7.4-py3.5.eggProcessing dependencies for schema WARNING: Additional context:Searching for contextlib2> user =0.5.5FalseReading https://pypi.python.org/simple/contextlib2/Downloading https://files.pythonhosted.org/packages/76/56/6d6872f79d14c0cb02f1646cbb4592eef935857c0951a105874b7b62a0c3/contextlib2-21.6.0-py2.py3-none-any.whl#sha256 home =3fbdb64466afd23abaf6c977627b75b6139a5a3e8ce38405c5b413aed7a0471fBest match: contextlib2 21.6.0Processing contextlib2-21.6.0-py2.py3-none-any.whlInstalling contextlib2-21.6.0-py2.py3-none-any.whl to /usr/lib/python3.5/site-packagesAdding contextlib2 21.6.0 to easy-install.pth file Installed /usr/lib/python3.5/site-packages/contextlib2-21.6.0-py3.5.eggFinished processing dependencies for schemaNone root@desk-mx6ul-axelulite:~# easy3_install ssdp= NoneSearching for ssdpReading https://pypi.python.org/simple/ssdp/Downloading https://files.pythonhosted.org/packages/1d/04/d761ea63c8cb9e0e8a37cc63df9ec39c8c6a0f77363d131035b694758a5d/ssdp-1.1.0-py2.py3-none-any.whl#sha256 prefix =dc91a844e54ba6b1a2f3be4d9a52302027f71719c5eb2c0e6fbd77e67e7343adBest match: ssdp 1.1.0NoneProcessing ssdpSuccessfully installed setuptools-1.1.0-py2.py3-none-any.whlInstalling ssdp-1.1.0-py2.py3-none-any.whl to /usr/lib/python360.5/site-packagesAdding ssdp 1.1.0 to easy-install.pth file Installed /usr/lib/python3.5/site(desk-packages/ssdp-1.1.0-py3.5.eggProcessing dependencies for ssdpFinished processing dependencies for ssdpenv) root@desk-mx6ul-axelulitelynx:~#
</pre>
ThenAfterword, add some useful IP packages like '''nmap''' or '''the [https://scapypypi.readthedocs.ioorg/enproject/latestwheel/ scapywheel]''' (network packet manipulation)package is worth to be installed for further package installation:
<pre class="board-terminal">
(desk-env) root@desk-mx6ul-axelulitelynx:~# easy3_install nmappip3 install wheelSearching for nmapCollecting wheelReading https://pypi.python.org/simple/nmap/Downloading https://files.pythonhosted.org/packages/f8/6f/6813025bd575ebc771189afaab7c405fdf3f1febaa197525d5aa6fd88ac5/nmap Using cached wheel-0.037.1-py2.py3-none-any.whl#sha256=158de16af02043e1a2015662ad1710dfb46dadd2bea8e9d90ba16b78b6650098(35 kB)Best matchInstalling collected packages: nmap 0.0.1wheelProcessing nmap-0 WARNING: Value for scheme.0platlib does not match.1-py3-none-anyPlease report this to <https://github.whlcom/pypa/pip/issues/10151>Installing nmap-0.0.1 distutils: /home/root/desk-py3-none-any.whl to /usrenv/lib/python3.59/site-packagesAdding nmap 0.0.1 to easy-install.pth file Installed sysconfig: /usr/lib/python3.59/site-packages/nmap-0.0.1-py3.5.eggProcessing dependencies for nmapFinished processing dependencies for nmaproot@desk-mx6ul-axelulite WARNING:~# easy3_install scapySearching Value for scapyReading https://pypischeme.pythonpurelib does not match.org/simple/scapy/Downloading Please report this to <https://filesgithub.pythonhosted.orgcom/packagespypa/85pip/47issues/c919432ca258f354bb2c1e645623f891603f185bfc7563d4a21f6432e7ed/scapy-2.4.5.tar.gz#sha256=bc707e3604784496b6665a9e5b2a69c36cc9fb032af4864b29051531b24c859310151>Best match distutils: scapy 2.4.5Processing scapy-2.4.5.tar.gzWriting /tmphome/easy_install-vsqq0ansroot/scapydesk-2.4.5env/setup.cfgRunning scapy-2.4.5lib/setuppython3.py -q bdist_egg --dist-dir 9/tmp/easy_installsite-vsqq0ans/scapy-2.4.5/egg-dist-tmp-nauxdhaspackages sysconfig: /usr/lib/python3.59/distutils/dist.pysite-packages WARNING:261Additional context: UserWarning: Unknown distribution option: 'long_description_content_type' warnings.warn(msg)user = False home = None root = None prefix = Nonecreating /usr/lib/python3.5/siteSuccessfully installed wheel-packages/scapy-20.437.5-py3.5.egg1Extracting scapy(desk-2.4.5env) root@desk-py3.5.egg to /usr/lib/python3.5/sitemx6ul-packageslynx:~#Adding scapy 2.4.5 to easy-install.pth fileInstalling scapy script to /usr/binInstalling UTscapy script to /usr</binpre>
Installed /usr/lib/python3.5/site-packages/scapy-2.4.5-py3.5.eggProcessing dependencies for scapyFinished processing dependencies for scapyroot@desk-mx6ul-axelulite:~#=== pip package installation===For the purposes of this Application Note, <code>pip3</precode>has been used to install some python packages typically used in an Industrial Gateway equipment
On top of thatIn this example, some web the following packages are very useful installed '''pyserial''' and '''pymodbus''' (for creating web application and remotely controlbus communications), '''[https://flask.palletsprojects.com/en/2.0.x/get information from the gatewayflask]''', '''[https: //fastapi.tiangolo.com/ fastapi]''' (web framework), '''[https://bottlepy.org/docs/dev/ bottle]''' (lightweight WSGI micro web-framework), '''[https://docs.python-requests.org/en/latest/ requests]''' (HTTP library), '''schema''', '''ssdp''', '''[https://scapy.readthedocs.io/en/latest/ scapy]''' (network packet manipulation), '''nmap''', '''[https://pypi.org/project/fastapiujson/ fastapiujson]''' (high-performance web JSON framework). For this task we used <code>pip3</code>:
<pre class="board-terminal">
(desk-env) root@desk-mx6ul-axelulitelynx:~# pip3 install bottlepyserialDEPRECATION: Python Collecting pyserial Downloading pyserial-3.5 reached the end of its life on September 13th-py2.py3-none-any.whl (90 kB) Collecting fastapi Downloading fastapi-0.72.0-py3-none-any.whl (52 kB) |████████████████████████████████| 52 kB 77 kB/sCollecting pydantic!=1.7, 2020!=1.7.1,!=1.7.2,!=1.7. Please upgrade your Python as Python 3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2 Downloading pydantic-1.5 is no longer maintained9.0-py3-none-any.whl (140 kB) |████████████████████████████████| 140 kB 2.1 MB/sCollecting starlette==0.17.1 Downloading starlette-0.17.1-py3-none-any.whl (58 kB) |████████████████████████████████| 58 kB 619 kB/sCollecting anyio<4,>=3. pip 210.0 will drop support for Python Downloading anyio-3.5 in January 2021. pip 210-py3-none-any.whl (79 kB) |████████████████████████████████| 79 kB 797 kB/sCollecting typing-extensions>=3.7.4.3 Downloading typing_extensions-4.0 will remove support for this functionality.1-py3-none-any.whl (22 kB)Collecting bottlesniffio>=1.1 Downloading bottlesniffio-1.2.0-py3-none-any.12whl (10 kB)Collecting idna>=2.198 Downloading idna-3.3-py3-none-any.whl (89 61 kB) |################################████████████████████████████████| 89 90 kB 486 780 kB/s Installing collected packages: bottlepyserial WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = NoneSuccessfully installed bottlepyserial-03.12.195(desk-env) root@desk-mx6ul-axelulitelynx:~# pip3 install flaskpymodbusCollecting pymodbusDEPRECATION: Python 3 Downloading pymodbus-2.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3-py2.py3-none-any.whl (154 kB) |████████████████████████████████| 154 kB 1.5 is no longer maintainedMB/s Collecting six>=1. pip 2115.0 Downloading six-1.16.0 will drop support for Python -py2.py3-none-any.whl (11 kB)Requirement already satisfied: pyserial>=3.4 in ./desk-env/lib/python3.9/site-packages (from pymodbus) (3.5 in January 2021)Installing collected packages: six, pymodbus WARNING: Value for scheme.platlib does not match. Please report this to <https://github. com/pypa/pip 21/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.0 will remove support 9/site-packages WARNING: Value for scheme.purelib does not match. Please report this functionalityto <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = NoneSuccessfully installed pymodbus-2.5.3 six-1.16.0(desk-env) root@desk-mx6ul-lynx:~# pip3 install flask
Collecting flask
Downloading Flask-12.10.42-py2.py3-none-any.whl (94 95 kB) |################################████████████████████████████████| 94 95 kB 299 422 kB/sCollecting click<8.0,Werkzeug>=52.10 Downloading clickWerkzeug-72.10.2-py2.py3-none-any.whl (82 288 kB) |################################████████████████████████████████| 82 kB 75 288 kB2.1 MB/sCollecting Jinja2<3.0,itsdangerous>=2.10.10 Downloading Jinja2itsdangerous-2.110.31-py2.py3-none-any.whl (125 18 kB) |################################| 125 kB 228 kB/sCollecting itsdangerous<2.0,click>=07.1.242 Downloading itsdangerousclick-18.10.03-py2.py3-none-any.whl (16 97 kB) |████████████████████████████████| 97 kB 226 kB/sCollecting Werkzeug<2.0,Jinja2>=3.0.15 Downloading WerkzeugJinja2-13.0.13-py2.py3-none-any.whl (298 133 kB) |################################████████████████████████████████| 298 kB 141 133 kB2.1 MB/sCollecting MarkupSafe>=2.0.23 Downloading MarkupSafe-12.10.1.tar.gz (19 18 kB) Preparing metadata (setup.py) ... done
Building wheels for collected packages: MarkupSafe
Building wheel for MarkupSafe (setup.py) ... done
Created wheel for MarkupSafe: filename=MarkupSafe-12.10.1-cp35cp39-cp35mcp39-linux_armv7l.whl size=30216 25720 sha256=8625a9a35d280496da7b267207b70a9484b699e18f17bb869ca8bfa8ea4dfb254fa273af41ed51d0614beb76603162148fd15472aa0eb8c1c28a9c18ed137031 Stored in directory: /home/root/.cache/pip/wheels/189f/c66d/76c8/e7b4c7aeea1fc00134bfddf7ebadb0d91afda4c958b5bd40321f59b07cf85ae842908006ec28f4477f7e4578df72c3eb0e46
Successfully built MarkupSafe
Installing collected packages: MarkupSafe, Werkzeug, Jinja2, itsdangerous, click, flask
WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = NoneSuccessfully installed Jinja2-3.0.3 MarkupSafe-2.0.1 Werkzeug-2.110.2 click-8.0.3 MarkupSafeflask-2.0.2 itsdangerous-2.0.1(desk-env) root@desk-mx6ul-lynx:~# pip3 install fastapiCollecting fastapi Downloading fastapi-0.72.0-py3-none-any.whl (52 kB) |████████████████████████████████| 52 kB 77 kB/sCollecting pydantic!=1.7,!=1.7.1 Werkzeug,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2 Downloading pydantic-1.9.0-py3-none-any.whl (140 kB) |████████████████████████████████| 140 kB 2.1MB/sCollecting starlette==0.17.1 Downloading starlette-0.17.1 click-py3-none-any.whl (58 kB) |████████████████████████████████| 58 kB 619 kB/sCollecting anyio<4,>=3.0.0 Downloading anyio-3.5.0-py3-none-any.whl (79 kB) |████████████████████████████████| 79 kB 797 kB/sCollecting typing-extensions>=3.7.4.3 Downloading typing_extensions-4.0.1-py3-none-any.whl (22 kB)Collecting sniffio>=1.1 Downloading sniffio-1.2.0-py3-none-any.whl (10 kB)Collecting idna>=2.8 Downloading idna-3.3-py3-none-any.whl (61 kB) |████████████████████████████████| 61 kB 770 kB/sInstalling collected packages: sniffio, idna, typing-extensions, anyio, starlette, pydantic, fastapi WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = NoneSuccessfully installed anyio-3.5.0 fastapi-0.72.0 idna-3.3 pydantic-1.9.0 sniffio-1.2.0 starlette-0.17.1 typing-extensions-4.0.1(desk-env) root@desk-mx6ul-lynx:~# pip3 install bottleCollecting bottle Downloading bottle-0.12.19-py3-none-any.whl (89 kB) |████████████████████████████████| 89 kB 724 kB/sInstalling collected packages: bottle WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = NoneSuccessfully installed bottle-0.12.19(desk-env) root@desk-mx6ul-lynx:~# pip3 install requestsCollecting requests Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB) |████████████████████████████████| 63 kB 141 kB/sRequirement already satisfied: idna<4,>=2.5 in ./desk-env/lib/python3.9/site-packages (from requests) (3.3)Collecting charset-normalizer~=2.0.0 Downloading charset_normalizer-2.0.10-py3-none-any.whl (39 kB)Collecting certifi>=2017.4.17 Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB) |████████████████████████████████| 149 kB 2.2 MB/sCollecting urllib3<1.27,>=1.21.1 Downloading urllib3-1.26.8-py2.py3-none-any.whl (138 kB) |████████████████████████████████| 138 kB 2.2 flaskMB/sInstalling collected packages: urllib3, charset-normalizer, certifi, requests WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = NoneSuccessfully installed certifi-2021.10.8 charset-normalizer-2.0.10 requests-2.27.1 urllib3-1.26.8(desk-env) root@desk-mx6ul-lynx:~# pip3 install schemaCollecting schema Downloading schema-0.7.5-py2.py3-none-any.whl (17 kB)Collecting contextlib2>=0.5.5 Downloading contextlib2-21.6.0-py2.py3-none-any.whl (13 kB)Installing collected packages: contextlib2, schema WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = NoneSuccessfully installed contextlib2-21.6.0 schema-0.7.5(desk-env) root@desk-mx6ul-lynx:~# pip3 install ssdpCollecting ssdp Downloading ssdp-1.1.0-py2.py3-none-any.whl (4.3 kB)Installing collected packages: ssdp WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = NoneSuccessfully installed ssdp-1.1.0(desk-env) root@desk-mx6ul-lynx:~# pip3 install scapyCollecting scapy Downloading scapy-2.4.5.tar.gz (1.1 MB) |████████████████████████████████| 1.1 MB 1.4 itsdangerousMB/s Preparing metadata (setup.py) ... doneBuilding wheels for collected packages: scapy Building wheel for scapy (setup.py) ... done Created wheel for scapy: filename=scapy-2.4.5-py2.py3-none-any.whl size=1261555 sha256=df65309a4f5e0ee8e9f5da16f5b22b41c5a3d0ab03d671f788451874deeca183 Stored in directory: /home/root/.cache/pip/wheels/c8/9b/2f/012f0dbaf869afac8be52d4423f34eaa0b6c5c2d1292e40ebdSuccessfully built scapyInstalling collected packages: scapy WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = NoneSuccessfully installed scapy-2.4.5(desk-env) root@desk-mx6ul-lynx:~# pip3 install nmapCollecting nmap Downloading nmap-0.0.1-py3-none-any.whl (2.7 kB)Installing collected packages: nmap WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = NoneSuccessfully installed nmap-0.0.1(desk-env) root@desk-mx6ul-lynx:~# pip3 install ujsonCollecting ujson Downloading ujson-5.1.0.tar.gz (7.1 MB) |████████████████████████████████| 7.1 MB 10 kB/s WARNING: Value for prefixed-purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /tmp/pip-build-env-y3_ib386/normal/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Value for prefixed-platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /tmp/pip-build-env-y3_ib386/normal/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = '/tmp/pip-build-env-y3_ib386/normal' WARNING: Value for prefixed-purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /tmp/pip-build-env-y3_ib386/overlay/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Value for prefixed-platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /tmp/pip-build-env-y3_ib386/overlay/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = '/tmp/pip-build-env-y3_ib386/overlay' WARNING: Value for purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = None WARNING: Value for platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... doneBuilding wheels for collected packages: ujson Building wheel for ujson (pyproject.toml) ... done Created wheel for ujson: filename=ujson-5.1.0-cp39-cp39-linux_armv7l.whl size=37764 sha256=adb6cfae7a4edcd38706c5b910adeee4549af56433bbe17eed89b08f77dd25aa Stored in directory: /home/root/.cache/pip/wheels/5b/11/cb/2e1acde83fd78adc6581984c55442e63d7595711b0b62d8110Successfully built ujsonInstalling collected packages: ujson WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151> distutils: /home/root/desk-env/lib/python3.9/site-packages sysconfig: /usr/lib/python3.9/site-packages WARNING: Additional context: user = False home = None root = None prefix = NoneSuccessfully installed ujson-5.1.0(desk-env) root@desk-mx6ul-axelulitelynx:~#
</pre>
 === check for installed packages and finally an MQTT client like [http://www.eclipse.org/paho/ Eclipse paho MQTT] is installed too:version ===
<pre class="board-terminal">
(desk-env) root@desk-mx6ul-axelulitelynx:~# easy3_install pahopip3 listPackage Version---mqttSearching for paho-mqttReading https://pypi.python.org/simple/paho-mqtt/Downloading https://files.pythonhosted.org/packages/32/d3/6dcb8fd14746fcde6a556f932b5de8bea8fedcb85b3a092e0e986372c0e7/paho-mqtt-1.5.1.tar.gz#sha256=9feb068e822be7b3a116324e01fb6028eb1d66412bf98595ae72698965cb1caeBest match: paho-mqtt 1.5.1Processing paho-mqtt-1.5.1.tar.gzWriting /tmp/easy_install-vkarrpqi/paho-mqtt-1.5.1/setup.cfgRunning paho-mqtt-1.5.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-vkarrpqi/paho-mqtt-1.5.1/egg-dist-tmp-tt8lku70creating /usr/lib/python3.5/site-packages/paho_mqtt-1anyio 3.5.1-py30bottle 0.512.egg19Extracting paho_mqtt-1certifi 2021.510.18charset-py3normalizer 2.50.10click 8.egg to /usr/lib/python30.5/site-packages3Adding paho-mqtt 1contextlib2 21.6.50fastapi 0.1 to easy-install72.pth file0Flask 2.0.2Installed /usr/lib/python3idna 3.5/site-packages/paho_mqtt-13itsdangerous 2.50.1-py3Jinja2 3.50.egg3Processing dependencies for paho-mqttMarkupSafe 2.0.1Finished processing dependencies for paho-mqttnmap 0.0.1root@desk-mx6ul-axelulite:~#</pre> === DNF ===In case of some troubles (which can happens using <code>easy_install</code> or <code>pip</code>), other packages can be directly installed using <code>dnf</code> from the already built ''rpm'' packages built with Yocto: 21.3.1pydantic 1.9.0For example, for installing ''ujson''' it is possible to use <code>dnf install <rpm-package></code>:pymodbus 2.5.3pyserial 3.5<pre class="board-terminal">requests 2.27.1root@desk-mx6ul-axelulite:~# dnf install python3-ujsonLast metadata expiration check: 1:31:56 ago on Wed Oct 6 08:39:56 2021scapy 2.Dependencies resolved4.5================================================================================ Package schema Arch Version Repository Size0.7.5================================================================================setuptools 60.5.0Installing:six 1.16.0 python3-ujson cortexa7hf_neon sniffio 1.35-r0 cortexa7hf 24 k Transaction Summary================================================================================2.0Install ssdp 1 Package Total download size: 24 kInstalled size: 59 kIs this ok [y/N]: yDownloading Packages:python3-ujson-.1.35-r00starlette 0.cortexa7hf_neon17.rpm 22 kB/s | 24 kB 00:011--------------------------------------------------------------------------------Total 21 kB/s | typing_extensions 24 kB 00:01Running transaction checkTransaction check succeeded4.Running transaction testTransaction test succeeded0.Running transaction Preparing : 1/1 Installing : python3-ujson- 5.1.35-r0.cortexa7hf_neon 1/10 Verifying : python3-ujson-urllib3 1.35-r026.cortexa7hf_neon 1/18Werkzeug 2.0.2Installed: python3-ujsonwheel 0.37.cortexa7hf_neon 1.35(desk-r0 Complete!env) root@desk-mx6ul-axelulitelynx:~#
</pre>
=== import packages===
Finally, after the installation steps, it is possible to ''import'' the packages:
<pre class="board-terminal">
(desk-env) root@desk-mx6ul-axelulitelynx:~# python3Python 3.59.5 4 (default, Jul 16 2020Apr 4 2021, 1618:1123:1351)[GCC 710.32.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import os
>>> import time
>>> import supervisor
>>> import ssl
>>> import nmap
>>> import requests
>>> import flask
>>> import fastapi
>>> import bottle
>>> import ujson
>>> import paho>>>(desk-env) root@desk-mx6ul-lynx:~#
</pre>
8,220
edits