Difference between revisions of "DESK-MX6UL-AN-0004: Using Python for Embedded applications"

From DAVE Developer's Wiki
Jump to: navigation, search
 
(32 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{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.}}
 
{{ImportantMessage|text=This application note has been validated using the '''kit version''' in the History table.}}
Line 9: Line 14:
 
!Development Kit version
 
!Development Kit version
 
|-
 
|-
| 1.0.1
+
| {{oldid|14782|1.0.0}}
 
| Oct 2021
 
| Oct 2021
|[[DESK-MX6UL-L/General/Release_Notes#DESK-MX6UL-L_1.0.1|DESK-MX6UL-L 1.0.1]]
+
|{{oldid|14780|DESK-MX6UL-L 1.0.1}}
 +
|-
 +
| 2.0.0
 +
| Apr 2022
 +
|[[DESK-MX6UL-L/General/Release_Notes#DESK-MX6UL-L_3.0.0|DESK-MX6UL-L 3.0.0]]
 
|-
 
|-
 
|}
 
|}
Line 27: Line 36:
 
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.''
 
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 adding <code>python3</code> libraries to the [[SBC_Lynx_SBC | SBC Lynx]] platform.
+
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 ==
 
== Python on DESK ==
<code>python</code> and <code>python3</code> application are already present on [[DESK-MX6UL-L/Development/Building_the_Yocto_BSP#Quick_reference | DESK-MX6UL-L]] <code>dave-image-devel</code> root file system.
+
<code>python3</code> 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 ==
 
== Installing python packages ==
Line 38: Line 45:
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@desk-mx6ul-axelulite:~# python3 --version
+
root@desk-mx6ul-lynx:~# python3 --version
Python 3.5.5
+
Python 3.9.4
root@desk-mx6ul-axelulite:~# pip --version
+
root@desk-mx6ul-lynx:~#  
pip 9.0.3 from /usr/lib/python2.7/site-packages (python 2.7)
 
root@desk-mx6ul-axelulite:~# easy3_install --version
 
setuptools 39.0.0 from /usr/lib/python3.5/site-packages (Python 3.5)
 
root@desk-mx6ul-axelulite:~#
 
 
</pre>
 
</pre>
  
Due to older pip version, it is worth to update <code>pip</code> before proceeding:
+
<code>pip3</code> is not present - ''by default'' - on standard root file system, but can be easily installed using python:
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@desk-mx6ul-axelulite:~# python -m pip install --upgrade pip
+
root@desk-mx6ul-lynx:~# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
 +
  % Total    % Received % Xferd  Average Speed  Time    Time    Time  Current
 +
                                Dload  Upload  Total  Spent    Left  Speed
 +
  0:00:01 --:--:-- 1846k
 +
root@desk-mx6ul-lynx:~# python3 get-pip.py
 
Collecting pip
 
Collecting pip
   Downloading https://files.pythonhosted.org/packages/27/79/8a850fe3496446ff0d584327ae44e7500daf6764ca1a382d2d02789accf7/pip-20.3.4-py2.py3-none-any.whl (1.5MB)
+
   Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
    100% |################################| 1.5MB 52kB/s
+
    |################| 1.7 MB 2.1 MB/s           
Installing collected packages: pip
+
Collecting setuptools
   Found existing installation: pip 9.0.3
+
  Downloading setuptools-60.5.0-py3-none-any.whl (958 kB)
    Uninstalling pip-9.0.3:
+
    |###########| 958 kB 2.1 MB/s          
      Successfully uninstalled pip-9.0.3
+
Collecting wheel
Successfully installed pip-20.3.4
+
   Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
You are using pip version 20.3.4, however version 21.2.4 is available.
+
Installing collected packages: wheel, setuptools, pip
You should consider upgrading via the 'pip install --upgrade pip' command.
+
Successfully installed pip-21.3.1 setuptools-60.5.0 wheel-0.37.1
root@desk-mx6ul-axelulite:~# pip --version
+
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
pip 20.3.4 from /usr/lib/python2.7/site-packages/pip (python 2.7)
+
root@desk-mx6ul-lynx:~#  
root@desk-mx6ul-axelulite:~#
 
 
</pre>
 
</pre>
  
=== easy install===
+
After the installation, <code>pip3</code> is the latest version available for '''Python3 3.9.4''':
Even if <code>easy_install</code> tool [https://setuptools.pypa.io/en/latest/deprecated/easy_install.html has been deprecated], it is a useful tool still present in the typical python distributions.
 
 
 
For the purposes of this Application Note, the tool has been used to install some python packages typically used in an Industrial Gateway equipment
 
 
 
In this example, the following packages are installed using ''easy_install'': '''pyserial''' and '''pymodbus''' (for bus communications), '''[https://docs.python-requests.org/en/latest/ requests]''' (HTTP library), '''schema''', '''ssdp''':  
 
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@desk-mx6ul-axelulite:~# easy3_install pyserial
+
root@desk-mx6ul-lynx:~# pip3 --version
Searching for pyserial
+
pip 21.3.1 from /usr/lib/python3.9/site-packages/pip (python 3.9)
Best match: pyserial 3.4
+
root@desk-mx6ul-lynx:~#
Adding pyserial 3.4 to easy-install.pth file
+
</pre>
  
Using /usr/lib/python3.5/site-packages
+
== Virtual environments ==
Processing dependencies for pyserial
+
As explained on [https://docs.python.org/3/tutorial/venv.html 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"''
Finished processing dependencies for pyserial
 
root@desk-mx6ul-axelulite:~# easy3_install pymodbus
 
Searching for pymodbus
 
Reading 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=e8cbf3594a8dd0f71c287e24d8365e69836c8d22cac5ab288110638fd2b9fda6
 
Best match: pymodbus 2.5.3rc1
 
Processing pymodbus-2.5.3rc1-py2.py3-none-any.whl
 
Installing pymodbus-2.5.3rc1-py2.py3-none-any.whl to /usr/lib/python3.5/site-packages
 
writing requirements to /usr/lib/python3.5/site-packages/pymodbus-2.5.3rc1-py3.5.egg/EGG-INFO/requires.txt
 
Adding pymodbus 2.5.3rc1 to easy-install.pth file
 
Installing pymodbus.server script to /usr/bin
 
Installing pymodbus.console script to /usr/bin
 
  
Installed /usr/lib/python3.5/site-packages/pymodbus-2.5.3rc1-py3.5.egg
+
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).
Processing dependencies for pymodbus
 
Searching for six>=1.15.0
 
Reading 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=8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254
 
Best match: six 1.16.0
 
Processing six-1.16.0-py2.py3-none-any.whl
 
Installing six-1.16.0-py2.py3-none-any.whl to /usr/lib/python3.5/site-packages
 
Adding six 1.16.0 to easy-install.pth file
 
  
Installed /usr/lib/python3.5/site-packages/six-1.16.0-py3.5.egg
+
* for example, create the <code>virtual environment</code> named '''desk'''
Finished processing dependencies for pymodbus
+
<pre class="board-terminal">
root@desk-mx6ul-axelulite:~# easy3_install requests
+
root@desk-mx6ul-lynx:~# python3 -m venv desk-env
Searching for requests
+
root@desk-mx6ul-lynx:~# which pip3
Reading https://pypi.python.org/simple/requests/
+
/usr/bin/pip3
Downloading https://files.pythonhosted.org/packages/92/96/144f70b972a9c0eabbd4391ef93ccd49d0f2747f4f6a2a2738e99e5adc65/requests-2.26.0-py2.py3-none-any.whl#sha256=6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24
+
root@desk-mx6ul-lynx:~#  
Best match: requests 2.26.0
+
</pre>
Processing requests-2.26.0-py2.py3-none-any.whl
+
* activate the <code>virtual environment</code>
Installing requests-2.26.0-py2.py3-none-any.whl to /usr/lib/python3.5/site-packages
+
<pre class="board-terminal">
writing requirements to /usr/lib/python3.5/site-packages/requests-2.26.0-py3.5.egg/EGG-INFO/requires.txt
+
root@desk-mx6ul-lynx:~# source desk-env/bin/activate
Adding requests 2.26.0 to easy-install.pth file
 
 
 
Installed /usr/lib/python3.5/site-packages/requests-2.26.0-py3.5.egg
 
Processing dependencies for requests
 
Searching for urllib3<1.27,>=1.21.1
 
Reading 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=c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844
 
Best match: urllib3 1.26.7
 
Processing urllib3-1.26.7-py2.py3-none-any.whl
 
Installing urllib3-1.26.7-py2.py3-none-any.whl to /usr/lib/python3.5/site-packages
 
writing requirements to /usr/lib/python3.5/site-packages/urllib3-1.26.7-py3.5.egg/EGG-INFO/requires.txt
 
Adding urllib3 1.26.7 to easy-install.pth file
 
 
 
Installed /usr/lib/python3.5/site-packages/urllib3-1.26.7-py3.5.egg
 
Searching for charset-normalizer~=2.0.0
 
Reading https://pypi.python.org/simple/charset-normalizer/
 
Downloading https://files.pythonhosted.org/packages/3f/65/69e6754102dcd018a0f29e4db673372eb323ee504431125ab6c9109cb21c/charset_normalizer-2.0.6-py3-none-any.whl#sha256=5d209c0a931f215cee683b6445e2d77677e7e75e159f78def0db09d68fafcaa6
 
Best match: charset-normalizer 2.0.6
 
Processing charset_normalizer-2.0.6-py3-none-any.whl
 
Installing charset_normalizer-2.0.6-py3-none-any.whl to /usr/lib/python3.5/site-packages
 
writing requirements to /usr/lib/python3.5/site-packages/charset_normalizer-2.0.6-py3.5.egg/EGG-INFO/requires.txt
 
Adding charset-normalizer 2.0.6 to easy-install.pth file
 
Installing normalizer script to /usr/bin
 
 
 
Installed /usr/lib/python3.5/site-packages/charset_normalizer-2.0.6-py3.5.egg
 
Searching for certifi>=2017.4.17
 
Reading https://pypi.python.org/simple/certifi/
 
Downloading https://files.pythonhosted.org/packages/05/1b/0a0dece0e8aa492a6ec9e4ad2fe366b511558cdc73fd3abc82ba7348e875/certifi-2021.5.30-py2.py3-none-any.whl#sha256=50b1e4f8446b06f41be7dd6338db18e0990601dce795c2b1686458aa7e8fa7d8
 
Best match: certifi 2021.5.30
 
Processing certifi-2021.5.30-py2.py3-none-any.whl
 
Installing certifi-2021.5.30-py2.py3-none-any.whl to /usr/lib/python3.5/site-packages
 
Adding certifi 2021.5.30 to easy-install.pth file
 
 
 
Installed /usr/lib/python3.5/site-packages/certifi-2021.5.30-py3.5.egg
 
Finished processing dependencies for requests
 
root@desk-mx6ul-axelulite:~# easy3_install schema
 
Searching for schema
 
Reading https://pypi.python.org/simple/schema/
 
Downloading https://files.pythonhosted.org/packages/c7/64/497632c9dc3c1bc94a92d9cafdc5cbd21d011bb651952765195739129a49/schema-0.7.4-py2.py3-none-any.whl#sha256=cf97e4cd27e203ab6bb35968532de1ed8991bce542a646f0ff1d643629a4945d
 
Best match: schema 0.7.4
 
Processing schema-0.7.4-py2.py3-none-any.whl
 
Installing schema-0.7.4-py2.py3-none-any.whl to /usr/lib/python3.5/site-packages
 
writing requirements to /usr/lib/python3.5/site-packages/schema-0.7.4-py3.5.egg/EGG-INFO/requires.txt
 
Adding schema 0.7.4 to easy-install.pth file
 
 
 
Installed /usr/lib/python3.5/site-packages/schema-0.7.4-py3.5.egg
 
Processing dependencies for schema
 
Searching for contextlib2>=0.5.5
 
Reading 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=3fbdb64466afd23abaf6c977627b75b6139a5a3e8ce38405c5b413aed7a0471f
 
Best match: contextlib2 21.6.0
 
Processing contextlib2-21.6.0-py2.py3-none-any.whl
 
Installing contextlib2-21.6.0-py2.py3-none-any.whl to /usr/lib/python3.5/site-packages
 
Adding contextlib2 21.6.0 to easy-install.pth file
 
 
 
Installed /usr/lib/python3.5/site-packages/contextlib2-21.6.0-py3.5.egg
 
Finished processing dependencies for schema
 
root@desk-mx6ul-axelulite:~# easy3_install ssdp
 
Searching for ssdp
 
Reading 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=dc91a844e54ba6b1a2f3be4d9a52302027f71719c5eb2c0e6fbd77e67e7343ad
 
Best match: ssdp 1.1.0
 
Processing ssdp-1.1.0-py2.py3-none-any.whl
 
Installing ssdp-1.1.0-py2.py3-none-any.whl to /usr/lib/python3.5/site-packages
 
Adding ssdp 1.1.0 to easy-install.pth file
 
 
 
Installed /usr/lib/python3.5/site-packages/ssdp-1.1.0-py3.5.egg
 
Processing dependencies for ssdp
 
Finished processing dependencies for ssdp
 
root@desk-mx6ul-axelulite:~#
 
 
</pre>
 
</pre>
 
+
* check and update ''pip3'' in the the <code>virtual environment</code>
Then, add some useful IP packages like '''nmap''' or '''[https://scapy.readthedocs.io/en/latest/ scapy]''' (network packet manipulation):
 
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@desk-mx6ul-axelulite:~# easy3_install nmap
+
(desk-env) root@desk-mx6ul-lynx:~# which pip3
Searching for nmap
+
/home/root/desk-env/bin/pip3
Reading https://pypi.python.org/simple/nmap/
+
(desk-env) root@desk-mx6ul-lynx:~# python3 -m pip install --upgrade pip
Downloading https://files.pythonhosted.org/packages/f8/6f/6813025bd575ebc771189afaab7c405fdf3f1febaa197525d5aa6fd88ac5/nmap-0.0.1-py3-none-any.whl#sha256=158de16af02043e1a2015662ad1710dfb46dadd2bea8e9d90ba16b78b6650098
+
Collecting pip
Best match: nmap 0.0.1
+
  Using cached pip-21.3.1-py3-none-any.whl (1.7 MB)
Processing nmap-0.0.1-py3-none-any.whl
+
Installing collected packages: pip
Installing nmap-0.0.1-py3-none-any.whl to /usr/lib/python3.5/site-packages
+
  Attempting uninstall: pip
Adding nmap 0.0.1 to easy-install.pth file
+
    Found existing installation: pip 20.2.3
 
+
    Uninstalling pip-20.2.3:
Installed /usr/lib/python3.5/site-packages/nmap-0.0.1-py3.5.egg
+
      Successfully uninstalled pip-20.2.3
Processing dependencies for nmap
+
Successfully installed pip-21.3.1
Finished processing dependencies for nmap
+
(desk-env) root@desk-mx6ul-lynx:~# pip3 --version
root@desk-mx6ul-axelulite:~# easy3_install scapy
+
pip 21.3.1 from /home/root/desk-env/lib/python3.9/site-packages/pip (python 3.9)
Searching for scapy
+
(desk-env) root@desk-mx6ul-lynx:~#  
Reading https://pypi.python.org/simple/scapy/
 
Downloading https://files.pythonhosted.org/packages/85/47/c919432ca258f354bb2c1e645623f891603f185bfc7563d4a21f6432e7ed/scapy-2.4.5.tar.gz#sha256=bc707e3604784496b6665a9e5b2a69c36cc9fb032af4864b29051531b24c8593
 
Best match: scapy 2.4.5
 
Processing scapy-2.4.5.tar.gz
 
Writing /tmp/easy_install-vsqq0ans/scapy-2.4.5/setup.cfg
 
Running scapy-2.4.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-vsqq0ans/scapy-2.4.5/egg-dist-tmp-nauxdhas
 
/usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
 
  warnings.warn(msg)
 
creating /usr/lib/python3.5/site-packages/scapy-2.4.5-py3.5.egg
 
Extracting scapy-2.4.5-py3.5.egg to /usr/lib/python3.5/site-packages
 
Adding scapy 2.4.5 to easy-install.pth file
 
Installing scapy script to /usr/bin
 
Installing UTscapy script to /usr/bin
 
 
 
Installed /usr/lib/python3.5/site-packages/scapy-2.4.5-py3.5.egg
 
Processing dependencies for scapy
 
Finished processing dependencies for scapy
 
root@desk-mx6ul-axelulite:~#
 
 
</pre>
 
</pre>
  
On top of that, some web packages are very useful for creating web application and remotely control/get information from the gateway: '''[https://bottlepy.org/docs/dev/ bottle]''' (lightweight WSGI micro web-framework), '''[https://pypi.org/project/fastapi/ fastapi]''' (high-performance web framework):
+
* <code>setuptools</code> can be upgraded too:
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@desk-mx6ul-axelulite:~# easy3_install bottle
+
(desk-env) root@desk-mx6ul-lynx:~# pip3 install --upgrade setuptools
Searching for bottle
+
Requirement already satisfied: setuptools in ./desk-env/lib/python3.9/site-packages (49.2.1)
Reading https://pypi.python.org/simple/bottle/
+
Collecting setuptools
Downloading https://files.pythonhosted.org/packages/bf/44/aeafdd6ca05a8e1c3f91eeeb272a202d5cb1b3b23730a5ca686a81c48d24/bottle-0.12.19-py3-none-any.whl#sha256=f6b8a34fe9aa406f9813c02990db72ca69ce6a158b5b156d2c41f345016a723d
+
  Using cached setuptools-60.5.0-py3-none-any.whl (958 kB)
Best match: bottle 0.12.19
+
Installing collected packages: setuptools
Processing bottle-0.12.19-py3-none-any.whl
+
  Attempting uninstall: setuptools
Installing bottle-0.12.19-py3-none-any.whl to /usr/lib/python3.5/site-packages
+
    Found existing installation: setuptools 49.2.1
Adding bottle 0.12.19 to easy-install.pth file
+
    Uninstalling setuptools-49.2.1:
Installing bottle.py script to /usr/bin
+
      Successfully uninstalled setuptools-49.2.1
 
+
  WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
Installed /usr/lib/python3.5/site-packages/bottle-0.12.19-py3.5.egg
+
  distutils: /home/root/desk-env/lib/python3.9/site-packages
Processing dependencies for bottle
+
  sysconfig: /usr/lib/python3.9/site-packages
Finished processing dependencies for bottle
+
  WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
root@desk-mx6ul-axelulite:~# easy3_install fastapi
+
  distutils: /home/root/desk-env/lib/python3.9/site-packages
Searching for fastapi
+
  sysconfig: /usr/lib/python3.9/site-packages
Reading https://pypi.python.org/simple/fastapi/
+
  WARNING: Additional context:
Downloading https://files.pythonhosted.org/packages/92/a8/10d8a171afa66e6e8a5cfe82771d11c4c84a2a874c19c0b55c7099001fac/fastapi-0.68.2-py3-none-any.whl#sha256=36bcdd3dbea87c586061005e4a40b9bd0145afd766655b4e0ec1d8870b32555c
+
  user = False
Best match: fastapi 0.68.2
+
  home = None
Processing fastapi-0.68.2-py3-none-any.whl
+
  root = None
Installing fastapi-0.68.2-py3-none-any.whl to /usr/lib/python3.5/site-packages
+
  prefix = None
writing requirements to /usr/lib/python3.5/site-packages/fastapi-0.68.2-py3.5.egg/EGG-INFO/requires.txt
+
Successfully installed setuptools-60.5.0
Adding fastapi 0.68.2 to easy-install.pth file
+
(desk-env) root@desk-mx6ul-lynx:~#
 
 
Installed /usr/lib/python3.5/site-packages/fastapi-0.68.2-py3.5.egg
 
Processing dependencies for fastapi
 
Searching for starlette==0.14.2
 
Reading https://pypi.python.org/simple/starlette/
 
Downloading https://files.pythonhosted.org/packages/15/34/db1890f442a1cd3a2c761f4109a0eb4e63503218d70a8c8e97faa09a5500/starlette-0.14.2-py3-none-any.whl#sha256=3c8e48e52736b3161e34c9f0e8153b4f32ec5d8995a3ee1d59410d92f75162ed
 
Best match: starlette 0.14.2
 
Processing starlette-0.14.2-py3-none-any.whl
 
Installing starlette-0.14.2-py3-none-any.whl to /usr/lib/python3.5/site-packages
 
writing requirements to /usr/lib/python3.5/site-packages/starlette-0.14.2-py3.5.egg/EGG-INFO/requires.txt
 
Adding starlette 0.14.2 to easy-install.pth file
 
 
 
Installed /usr/lib/python3.5/site-packages/starlette-0.14.2-py3.5.egg
 
Searching for pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2
 
Reading https://pypi.python.org/simple/pydantic/
 
Downloading https://files.pythonhosted.org/packages/ff/74/54e030641601112309f6d2af620774e9080f99c7a15742fc6a0b170c4076/pydantic-1.8.2-py3-none-any.whl#sha256=fec866a0b59f372b7e776f2d7308511784dace622e0992a0b59ea3ccee0ae833
 
Best match: pydantic 1.8.2
 
Processing pydantic-1.8.2-py3-none-any.whl
 
Installing pydantic-1.8.2-py3-none-any.whl to /usr/lib/python3.5/site-packages
 
writing requirements to /usr/lib/python3.5/site-packages/pydantic-1.8.2-py3.5.egg/EGG-INFO/requires.txt
 
Adding pydantic 1.8.2 to easy-install.pth file
 
 
 
Installed /usr/lib/python3.5/site-packages/pydantic-1.8.2-py3.5.egg
 
Searching for typing-extensions>=3.7.4.3
 
Reading https://pypi.python.org/simple/typing-extensions/
 
Downloading https://files.pythonhosted.org/packages/74/60/18783336cc7fcdd95dae91d73477830aa53f5d3181ae4fe20491d7fc3199/typing_extensions-3.10.0.2-py3-none-any.whl#sha256=f1d25edafde516b146ecd0613dabcc61409817af4766fbbcfb8d1ad4ec441a34
 
Best match: typing-extensions 3.10.0.2
 
Processing typing_extensions-3.10.0.2-py3-none-any.whl
 
Installing typing_extensions-3.10.0.2-py3-none-any.whl to /usr/lib/python3.5/site-packages
 
Adding typing-extensions 3.10.0.2 to easy-install.pth file
 
 
 
Installed /usr/lib/python3.5/site-packages/typing_extensions-3.10.0.2-py3.5.egg
 
Finished processing dependencies for fastapi
 
 
</pre>
 
</pre>
  
and finally an MQTT client like [http://www.eclipse.org/paho/ Eclipse paho MQTT] is installed too:
+
Afterword, the [https://pypi.org/project/wheel/ wheel] package is worth to be installed for further package installation:
 
 
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@desk-mx6ul-axelulite:~# easy3_install paho-mqtt
+
(desk-env) root@desk-mx6ul-lynx:~# pip3 install wheel
Searching for paho-mqtt
+
Collecting wheel
Reading https://pypi.python.org/simple/paho-mqtt/
+
  Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Downloading https://files.pythonhosted.org/packages/32/d3/6dcb8fd14746fcde6a556f932b5de8bea8fedcb85b3a092e0e986372c0e7/paho-mqtt-1.5.1.tar.gz#sha256=9feb068e822be7b3a116324e01fb6028eb1d66412bf98595ae72698965cb1cae
+
Installing collected packages: wheel
Best match: paho-mqtt 1.5.1
+
  WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
Processing paho-mqtt-1.5.1.tar.gz
+
  distutils: /home/root/desk-env/lib/python3.9/site-packages
Writing /tmp/easy_install-vkarrpqi/paho-mqtt-1.5.1/setup.cfg
+
  sysconfig: /usr/lib/python3.9/site-packages
Running paho-mqtt-1.5.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-vkarrpqi/paho-mqtt-1.5.1/egg-dist-tmp-tt8lku70
+
  WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
creating /usr/lib/python3.5/site-packages/paho_mqtt-1.5.1-py3.5.egg
+
  distutils: /home/root/desk-env/lib/python3.9/site-packages
Extracting paho_mqtt-1.5.1-py3.5.egg to /usr/lib/python3.5/site-packages
+
  sysconfig: /usr/lib/python3.9/site-packages
Adding paho-mqtt 1.5.1 to easy-install.pth file
+
  WARNING: Additional context:
 
+
  user = False
Installed /usr/lib/python3.5/site-packages/paho_mqtt-1.5.1-py3.5.egg
+
  home = None
Processing dependencies for paho-mqtt
+
  root = None
Finished processing dependencies for paho-mqtt
+
  prefix = None
root@desk-mx6ul-axelulite:~#
+
Successfully installed wheel-0.37.1
 +
(desk-env) root@desk-mx6ul-lynx:~#
 
</pre>
 
</pre>
  
=== DNF ===
+
=== pip package installation===
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:
+
For the purposes of this Application Note, <code>pip3</code> has been used to install some python packages typically used in an Industrial Gateway equipment
  
For example, for installing '''[https://flask.palletsprojects.com/en/2.0.x/ flask]''' or '''ujson''' it is possible to use <code>dnf install <rpm-package></code>:
+
In this example, the following packages are installed '''pyserial''' and '''pymodbus''' (for bus communications), '''[https://flask.palletsprojects.com/en/2.0.x/ flask]''', '''[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/ujson/ ujson]''' (JSON framework):  
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@desk-mx6ul-axelulite:~# dnf install python3-flask
+
(desk-env) root@desk-mx6ul-lynx:~# pip3 install pyserial
Last metadata expiration check: 0:13:01 ago on Wed Oct  6 08:39:56 2021.
+
Collecting pyserial
Dependencies resolved.
+
  Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB)
================================================================================
+
    Collecting fastapi
Package                  Arch              Version      Repository    Size
+
  Downloading fastapi-0.72.0-py3-none-any.whl (52 kB)
================================================================================
+
    |████████████████████████████████| 52 kB 77 kB/s
Installing:
+
Collecting pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2
python3-flask            cortexa7hf_neon    0.12.2-r0    cortexa7hf    110 k
+
  Downloading pydantic-1.9.0-py3-none-any.whl (140 kB)
Installing dependencies:
+
    |████████████████████████████████| 140 kB 2.1 MB/s
python3-click            cortexa7hf_neon    6.7-r0        cortexa7hf    110 k
+
Collecting starlette==0.17.1
python3-itsdangerous      cortexa7hf_neon    0.24-r0      cortexa7hf    23 k
+
  Downloading starlette-0.17.1-py3-none-any.whl (58 kB)
python3-jinja2           cortexa7hf_neon    2.10-r0      cortexa7hf    187 k
+
    |████████████████████████████████| 58 kB 619 kB/s
python3-markupsafe        cortexa7hf_neon    1.0-r0        cortexa7hf    25 k
+
Collecting anyio<4,>=3.0.0
python3-simplejson        cortexa7hf_neon    3.13.2-r0    cortexa7hf    50 k
+
  Downloading anyio-3.5.0-py3-none-any.whl (79 kB)
python3-werkzeug          cortexa7hf_neon    0.14.1-r0    cortexa7hf    375 k
+
    |████████████████████████████████| 79 kB 797 kB/s
python3-werkzeug-tests    cortexa7hf_neon    0.14.1-r0    cortexa7hf    32 k
+
Collecting typing-extensions>=3.7.4.3
 
+
  Downloading typing_extensions-4.0.1-py3-none-any.whl (22 kB)
Transaction Summary
+
Collecting sniffio>=1.1
================================================================================
+
  Downloading sniffio-1.2.0-py3-none-any.whl (10 kB)
Install  8 Packages
+
Collecting idna>=2.8
 
+
  Downloading idna-3.3-py3-none-any.whl (61 kB)
Total download size: 912 k
+
    |████████████████████████████████| 90 kB 780 kB/s           
Installed size: 3.7 M
+
Installing collected packages: pyserial
Is this ok [y/N]: y
+
  WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
Downloading Packages:
+
  distutils: /home/root/desk-env/lib/python3.9/site-packages
(1/8): python3-itsdangerous-0.24-r0.cortexa7hf_ 128 kB/s | 23 kB     00:00
+
  sysconfig: /usr/lib/python3.9/site-packages
(2/8): python3-flask-0.12.2-r0.cortexa7hf_neon. 344 kB/s | 110 kB     00:00
+
  WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
(3/8): python3-click-6.7-r0.cortexa7hf_neon.rpm 329 kB/s | 110 kB     00:00
+
  distutils: /home/root/desk-env/lib/python3.9/site-packages
(4/8): python3-jinja2-2.10-r0.cortexa7hf_neon.r 508 kB/s | 187 kB    00:00
+
  sysconfig: /usr/lib/python3.9/site-packages
(5/8): python3-werkzeug-tests-0.14.1-r0.cortexa 137 kB/s |  32 kB    00:00
+
  WARNING: Additional context:
(6/8): python3-markupsafe-1.0-r0.cortexa7hf_neo 318 kB/s |  25 kB    00:00
+
  user = False
(7/8): python3-simplejson-3.13.2-r0.cortexa7hf_ 220 kB/s |  50 kB    00:00
+
  home = None
(8/8): python3-werkzeug-0.14.1-r0.cortexa7hf_ne 684 kB/s | 375 kB    00:00
+
  root = None
--------------------------------------------------------------------------------
+
  prefix = None
Total                                          979 kB/s | 912 kB     00:00
+
Successfully installed pyserial-3.5
Running transaction check
+
(desk-env) root@desk-mx6ul-lynx:~# pip3 install pymodbus
Transaction check succeeded.
+
Collecting pymodbus
Running transaction test
+
  Downloading pymodbus-2.5.3-py2.py3-none-any.whl (154 kB)
Transaction test succeeded.
+
    |████████████████████████████████| 154 kB 1.5 MB/s            
Running transaction
+
Collecting six>=1.15.0
  Preparing        :                                                        1/1
+
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
   Installing      : python3-werkzeug-0.14.1-r0.cortexa7hf_neon            1/8
+
Requirement already satisfied: pyserial>=3.4 in ./desk-env/lib/python3.9/site-packages (from pymodbus) (3.5)
   Installing      : python3-werkzeug-tests-0.14.1-r0.cortexa7hf_neon      2/8
+
Installing collected packages: six, pymodbus
   Installing      : python3-markupsafe-1.0-r0.cortexa7hf_neon              3/8
+
  WARNING: Value for scheme.platlib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
   Installing      : python3-jinja2-2.10-r0.cortexa7hf_neon                4/8
+
  distutils: /home/root/desk-env/lib/python3.9/site-packages
   Installing      : python3-simplejson-3.13.2-r0.cortexa7hf_neon          5/8
+
  sysconfig: /usr/lib/python3.9/site-packages
  Installing       : python3-itsdangerous-0.24-r0.cortexa7hf_neon          6/8
+
  WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
   Installing      : python3-click-6.7-r0.cortexa7hf_neon                  7/8
+
  distutils: /home/root/desk-env/lib/python3.9/site-packages
   Installing      : python3-flask-0.12.2-r0.cortexa7hf_neon                8/8
+
  sysconfig: /usr/lib/python3.9/site-packages
   Verifying        : python3-flask-0.12.2-r0.cortexa7hf_neon                1/8
+
  WARNING: Additional context:
   Verifying        : python3-click-6.7-r0.cortexa7hf_neon                  2/8
+
  user = False
   Verifying        : python3-itsdangerous-0.24-r0.cortexa7hf_neon          3/8
+
  home = None
   Verifying        : python3-jinja2-2.10-r0.cortexa7hf_neon                4/8
+
  root = None
   Verifying        : python3-werkzeug-0.14.1-r0.cortexa7hf_neon            5/8
+
  prefix = None
  Verifying        : python3-werkzeug-tests-0.14.1-r0.cortexa7hf_neon      6/8
+
Successfully installed pymodbus-2.5.3 six-1.16.0
  Verifying        : python3-simplejson-3.13.2-r0.cortexa7hf_neon          7/8
+
(desk-env) root@desk-mx6ul-lynx:~# pip3 install flask
  Verifying        : python3-markupsafe-1.0-r0.cortexa7hf_neon              8/8
+
Collecting flask
 
+
  Downloading Flask-2.0.2-py3-none-any.whl (95 kB)
Installed:
+
    |████████████████████████████████| 95 kB 422 kB/s
   python3-flask.cortexa7hf_neon 0.12.2-r0
+
Collecting Werkzeug>=2.0
  python3-click.cortexa7hf_neon 6.7-r0
+
  Downloading Werkzeug-2.0.2-py3-none-any.whl (288 kB)
   python3-itsdangerous.cortexa7hf_neon 0.24-r0
+
    |████████████████████████████████| 288 kB 2.1 MB/s
   python3-jinja2.cortexa7hf_neon 2.10-r0
+
Collecting itsdangerous>=2.0
  python3-markupsafe.cortexa7hf_neon 1.0-r0
+
  Downloading itsdangerous-2.0.1-py3-none-any.whl (18 kB)
   python3-simplejson.cortexa7hf_neon 3.13.2-r0
+
Collecting click>=7.1.2
   python3-werkzeug.cortexa7hf_neon 0.14.1-r0
+
  Downloading click-8.0.3-py3-none-any.whl (97 kB)
   python3-werkzeug-tests.cortexa7hf_neon 0.14.1-r0
+
    |████████████████████████████████| 97 kB 226 kB/s
 
+
Collecting Jinja2>=3.0
Complete!
+
  Downloading Jinja2-3.0.3-py3-none-any.whl (133 kB)
root@desk-mx6ul-axelulite:~# dnf install python3-ujson
+
    |████████████████████████████████| 133 kB 2.1 MB/s
Last metadata expiration check: 1:31:56 ago on Wed Oct  6 08:39:56 2021.
+
Collecting MarkupSafe>=2.0
Dependencies resolved.
+
  Downloading MarkupSafe-2.0.1.tar.gz (18 kB)
================================================================================
+
  Preparing metadata (setup.py) ... done
Package            Arch                  Version      Repository        Size
+
Building wheels for collected packages: MarkupSafe
================================================================================
+
  Building wheel for MarkupSafe (setup.py) ... done
Installing:
+
  Created wheel for MarkupSafe: filename=MarkupSafe-2.0.1-cp39-cp39-linux_armv7l.whl size=25720 sha256=4fa273af41ed51d0614beb76603162148fd15472aa0eb8c1c28a9c18ed137031
python3-ujson      cortexa7hf_neon      1.35-r0      cortexa7hf        24 k
+
  Stored in directory: /home/root/.cache/pip/wheels/9f/6d/c8/1f59b07cf85ae842908006ec28f4477f7e4578df72c3eb0e46
 
+
Successfully built MarkupSafe
Transaction Summary
+
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>
Install  1 Package
+
  distutils: /home/root/desk-env/lib/python3.9/site-packages
 
+
  sysconfig: /usr/lib/python3.9/site-packages
Total download size: 24 k
+
  WARNING: Value for scheme.purelib does not match. Please report this to <https://github.com/pypa/pip/issues/10151>
Installed size: 59 k
+
  distutils: /home/root/desk-env/lib/python3.9/site-packages
Is this ok [y/N]: y
+
  sysconfig: /usr/lib/python3.9/site-packages
Downloading Packages:
+
  WARNING: Additional context:
python3-ujson-1.35-r0.cortexa7hf_neon.rpm        22 kB/s |  24 kB    00:01
+
  user = False
--------------------------------------------------------------------------------
+
  home = None
Total                                            21 kB/s |  24 kB    00:01
+
  root = None
Running transaction check
+
  prefix = None
Transaction check succeeded.
+
Successfully installed Jinja2-3.0.3 MarkupSafe-2.0.1 Werkzeug-2.0.2 click-8.0.3 flask-2.0.2 itsdangerous-2.0.1
Running transaction test
+
(desk-env) root@desk-mx6ul-lynx:~# pip3 install fastapi
Transaction test succeeded.
+
Collecting fastapi
Running transaction
+
  Downloading fastapi-0.72.0-py3-none-any.whl (52 kB)
  Preparing        :                                                       1/1
+
    |████████████████████████████████| 52 kB 77 kB/s
   Installing      : python3-ujson-1.35-r0.cortexa7hf_neon                  1/1
+
Collecting pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2
   Verifying        : python3-ujson-1.35-r0.cortexa7hf_neon                  1/1
+
  Downloading pydantic-1.9.0-py3-none-any.whl (140 kB)
 
+
    |████████████████████████████████| 140 kB 2.1 MB/s
Installed:
+
Collecting starlette==0.17.1
  python3-ujson.cortexa7hf_neon 1.35-r0
+
   Downloading starlette-0.17.1-py3-none-any.whl (58 kB)
 
+
    |████████████████████████████████| 58 kB 619 kB/s
Complete!
+
Collecting anyio<4,>=3.0.0
root@desk-mx6ul-axelulite:~#
+
   Downloading anyio-3.5.0-py3-none-any.whl (79 kB)
 +
    |████████████████████████████████| 79 kB 797 kB/s
 +
Collecting 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/s
 +
Installing 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 = None
 +
Successfully 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 bottle
 +
Collecting bottle
 +
   Downloading bottle-0.12.19-py3-none-any.whl (89 kB)
 +
    |████████████████████████████████| 89 kB 724 kB/s
 +
Installing 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 = None
 +
Successfully installed bottle-0.12.19
 +
(desk-env) root@desk-mx6ul-lynx:~# pip3 install requests
 +
Collecting requests
 +
  Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
 +
    |████████████████████████████████| 63 kB 141 kB/s
 +
Requirement 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/s
 +
Collecting urllib3<1.27,>=1.21.1
 +
  Downloading urllib3-1.26.8-py2.py3-none-any.whl (138 kB)
 +
    |████████████████████████████████| 138 kB 2.2 MB/s
 +
Installing 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 = None
 +
Successfully 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 schema
 +
Collecting 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 = None
 +
Successfully installed contextlib2-21.6.0 schema-0.7.5
 +
(desk-env) root@desk-mx6ul-lynx:~# pip3 install ssdp
 +
Collecting 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 = None
 +
Successfully installed ssdp-1.1.0
 +
(desk-env) root@desk-mx6ul-lynx:~# pip3 install scapy
 +
Collecting scapy
 +
  Downloading scapy-2.4.5.tar.gz (1.1 MB)
 +
    |████████████████████████████████| 1.1 MB 1.4 MB/s
 +
  Preparing metadata (setup.py) ... done
 +
Building 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/012f0dbaf869afac8be52d4423f34eaa0b6c5c2d1292e40ebd
 +
Successfully built scapy
 +
Installing 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 = None
 +
Successfully installed scapy-2.4.5
 +
(desk-env) root@desk-mx6ul-lynx:~# pip3 install nmap
 +
Collecting 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 = None
 +
Successfully installed nmap-0.0.1
 +
(desk-env) root@desk-mx6ul-lynx:~# pip3 install ujson
 +
Collecting 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) ... done
 +
Building 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/2e1acde83fd78adc6581984c55442e63d7595711b0b62d8110
 +
Successfully built ujson
 +
Installing 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 = None
 +
Successfully installed ujson-5.1.0
 +
(desk-env) root@desk-mx6ul-lynx:~#
 +
</pre>
 +
=== check for installed packages and version ===
 +
<pre class="board-terminal">
 +
(desk-env) root@desk-mx6ul-lynx:~# pip3 list
 +
Package            Version
 +
------------------ ---------
 +
anyio              3.5.0
 +
bottle            0.12.19
 +
certifi            2021.10.8
 +
charset-normalizer 2.0.10
 +
click              8.0.3
 +
contextlib2        21.6.0
 +
fastapi            0.72.0
 +
Flask              2.0.2
 +
idna              3.3
 +
itsdangerous      2.0.1
 +
Jinja2            3.0.3
 +
MarkupSafe        2.0.1
 +
nmap              0.0.1
 +
pip                21.3.1
 +
pydantic          1.9.0
 +
pymodbus          2.5.3
 +
pyserial          3.5
 +
requests          2.27.1
 +
scapy              2.4.5
 +
schema            0.7.5
 +
setuptools        60.5.0
 +
six                1.16.0
 +
sniffio            1.2.0
 +
ssdp              1.1.0
 +
starlette          0.17.1
 +
typing_extensions  4.0.1
 +
ujson              5.1.0
 +
urllib3            1.26.8
 +
Werkzeug          2.0.2
 +
wheel              0.37.1
 +
(desk-env) root@desk-mx6ul-lynx:~#  
 
</pre>
 
</pre>
  
As you can see, ''dnf'' automatically manage the dependencies: for example, ''flask '' procedure install also '''Jinja2'', ''Markupsafe'', ''simplejson'', ''Werkzeug''.
+
=== import packages===
 
 
== import packages==
 
 
Finally, after the installation steps, it is possible to ''import'' the packages:
 
Finally, after the installation steps, it is possible to ''import'' the packages:
  
 
<pre class="board-terminal">
 
<pre class="board-terminal">
root@desk-mx6ul-axelulite:~# python3
+
(desk-env) root@desk-mx6ul-lynx:~# python3
Python 3.5.5 (default, Jul 16 2020, 16:11:13)
+
Python 3.9.4 (default, Apr  4 2021, 18:23:51)  
[GCC 7.3.0] on linux
+
[GCC 10.2.0] on linux
 
Type "help", "copyright", "credits" or "license" for more information.
 
Type "help", "copyright", "credits" or "license" for more information.
 
>>> import sys
 
>>> import sys
 
>>> import os
 
>>> import os
 
>>> import time
 
>>> import time
>>> import supervisor
 
 
>>> import ssl
 
>>> import ssl
 
>>> import nmap
 
>>> import nmap
Line 437: Line 526:
 
>>> import requests
 
>>> import requests
 
>>> import flask
 
>>> import flask
 +
>>> import fastapi
 
>>> import bottle
 
>>> import bottle
 
>>> import ujson
 
>>> import ujson
>>> import paho
+
>>>  
>>>
+
(desk-env) root@desk-mx6ul-lynx:~#
 
</pre>
 
</pre>

Latest revision as of 09:14, 10 January 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 2021

DESK-MX6UL-L 1.0.1

2.0.0 Apr 2022 DESK-MX6UL-L 3.0.0

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 an Industrial IoT Gateway adding python3 libraries to the SBC Lynx platform.

Python on DESK[edit | edit source]

python3 application is already present on DESK-MX6UL-L dave-image-devel root file system.

Installing python packages[edit | edit source]

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

root@desk-mx6ul-lynx:~# python3 --version
Python 3.9.4
root@desk-mx6ul-lynx:~# 

pip3 is not present - by default - on standard root file system, but can be easily installed using python:

root@desk-mx6ul-lynx:~# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0:00:01 --:--:-- 1846k
root@desk-mx6ul-lynx:~# python3 get-pip.py 
Collecting pip
  Downloading pip-21.3.1-py3-none-any.whl (1.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 MB/s            
Collecting wheel
  Downloading wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel, setuptools, pip
Successfully installed pip-21.3.1 setuptools-60.5.0 wheel-0.37.1
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@desk-mx6ul-lynx:~# 

After the installation, pip3 is the latest version available for Python3 3.9.4:

root@desk-mx6ul-lynx:~# pip3 --version
pip 21.3.1 from /usr/lib/python3.9/site-packages/pip (python 3.9)
root@desk-mx6ul-lynx:~# 

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).

  • for example, create the virtual environment named desk
root@desk-mx6ul-lynx:~# python3 -m venv desk-env
root@desk-mx6ul-lynx:~# which pip3
/usr/bin/pip3
root@desk-mx6ul-lynx:~# 
  • activate the virtual environment
root@desk-mx6ul-lynx:~# source desk-env/bin/activate
  • check and update pip3 in the the virtual environment
(desk-env) root@desk-mx6ul-lynx:~# which pip3
/home/root/desk-env/bin/pip3
(desk-env) root@desk-mx6ul-lynx:~# python3 -m pip install --upgrade pip
Collecting pip
  Using cached pip-21.3.1-py3-none-any.whl (1.7 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.2.3
    Uninstalling pip-20.2.3:
      Successfully uninstalled pip-20.2.3
Successfully installed pip-21.3.1
(desk-env) root@desk-mx6ul-lynx:~# pip3 --version
pip 21.3.1 from /home/root/desk-env/lib/python3.9/site-packages/pip (python 3.9)
(desk-env) root@desk-mx6ul-lynx:~# 
  • setuptools can be upgraded too:
(desk-env) root@desk-mx6ul-lynx:~# pip3 install --upgrade setuptools
Requirement already satisfied: setuptools in ./desk-env/lib/python3.9/site-packages (49.2.1)
Collecting setuptools
  Using cached setuptools-60.5.0-py3-none-any.whl (958 kB)
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 49.2.1
    Uninstalling setuptools-49.2.1:
      Successfully uninstalled setuptools-49.2.1
  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 = None
Successfully installed setuptools-60.5.0
(desk-env) root@desk-mx6ul-lynx:~# 

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

(desk-env) root@desk-mx6ul-lynx:~# pip3 install wheel
Collecting wheel
  Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
  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 = None
Successfully installed wheel-0.37.1
(desk-env) root@desk-mx6ul-lynx:~#

pip package installation[edit | edit source]

For the purposes of this Application Note, pip3 has been used to install some python packages typically used in an Industrial Gateway equipment

In this example, the following packages are installed pyserial and pymodbus (for bus communications), flask, fastapi (web framework), bottle (lightweight WSGI micro web-framework), requests (HTTP library), schema, ssdp, scapy (network packet manipulation), nmap, ujson (JSON framework):

(desk-env) root@desk-mx6ul-lynx:~# pip3 install pyserial
Collecting pyserial
  Downloading pyserial-3.5-py2.py3-none-any.whl (90 kB)
     Collecting fastapi
  Downloading fastapi-0.72.0-py3-none-any.whl (52 kB)
     |████████████████████████████████| 52 kB 77 kB/s
Collecting pydantic!=1.7,!=1.7.1,!=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.1 MB/s
Collecting starlette==0.17.1
  Downloading starlette-0.17.1-py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 619 kB/s
Collecting anyio<4,>=3.0.0
  Downloading anyio-3.5.0-py3-none-any.whl (79 kB)
     |████████████████████████████████| 79 kB 797 kB/s
Collecting 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)
     |████████████████████████████████| 90 kB 780 kB/s            
Installing collected packages: pyserial
  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 = None
Successfully installed pyserial-3.5
(desk-env) root@desk-mx6ul-lynx:~# pip3 install pymodbus
Collecting pymodbus
  Downloading pymodbus-2.5.3-py2.py3-none-any.whl (154 kB)
     |████████████████████████████████| 154 kB 1.5 MB/s            
Collecting six>=1.15.0
  Downloading six-1.16.0-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)
Installing collected packages: six, pymodbus
  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 = None
Successfully installed pymodbus-2.5.3 six-1.16.0
(desk-env) root@desk-mx6ul-lynx:~# pip3 install flask
Collecting flask
  Downloading Flask-2.0.2-py3-none-any.whl (95 kB)
     |████████████████████████████████| 95 kB 422 kB/s
Collecting Werkzeug>=2.0
  Downloading Werkzeug-2.0.2-py3-none-any.whl (288 kB)
     |████████████████████████████████| 288 kB 2.1 MB/s
Collecting itsdangerous>=2.0
  Downloading itsdangerous-2.0.1-py3-none-any.whl (18 kB)
Collecting click>=7.1.2
  Downloading click-8.0.3-py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 226 kB/s
Collecting Jinja2>=3.0
  Downloading Jinja2-3.0.3-py3-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 2.1 MB/s
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.0.1.tar.gz (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-2.0.1-cp39-cp39-linux_armv7l.whl size=25720 sha256=4fa273af41ed51d0614beb76603162148fd15472aa0eb8c1c28a9c18ed137031
  Stored in directory: /home/root/.cache/pip/wheels/9f/6d/c8/1f59b07cf85ae842908006ec28f4477f7e4578df72c3eb0e46
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 = None
Successfully installed Jinja2-3.0.3 MarkupSafe-2.0.1 Werkzeug-2.0.2 click-8.0.3 flask-2.0.2 itsdangerous-2.0.1
(desk-env) root@desk-mx6ul-lynx:~# pip3 install fastapi
Collecting fastapi
  Downloading fastapi-0.72.0-py3-none-any.whl (52 kB)
     |████████████████████████████████| 52 kB 77 kB/s
Collecting pydantic!=1.7,!=1.7.1,!=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.1 MB/s
Collecting starlette==0.17.1
  Downloading starlette-0.17.1-py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 619 kB/s
Collecting anyio<4,>=3.0.0
  Downloading anyio-3.5.0-py3-none-any.whl (79 kB)
     |████████████████████████████████| 79 kB 797 kB/s
Collecting 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/s
Installing 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 = None
Successfully 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 bottle
Collecting bottle
  Downloading bottle-0.12.19-py3-none-any.whl (89 kB)
     |████████████████████████████████| 89 kB 724 kB/s
Installing 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 = None
Successfully installed bottle-0.12.19
(desk-env) root@desk-mx6ul-lynx:~# pip3 install requests
Collecting requests
  Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
     |████████████████████████████████| 63 kB 141 kB/s
Requirement 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/s
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.8-py2.py3-none-any.whl (138 kB)
     |████████████████████████████████| 138 kB 2.2 MB/s
Installing 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 = None
Successfully 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 schema
Collecting 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 = None
Successfully installed contextlib2-21.6.0 schema-0.7.5
(desk-env) root@desk-mx6ul-lynx:~# pip3 install ssdp
Collecting 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 = None
Successfully installed ssdp-1.1.0
(desk-env) root@desk-mx6ul-lynx:~# pip3 install scapy
Collecting scapy
  Downloading scapy-2.4.5.tar.gz (1.1 MB)
     |████████████████████████████████| 1.1 MB 1.4 MB/s
  Preparing metadata (setup.py) ... done
Building 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/012f0dbaf869afac8be52d4423f34eaa0b6c5c2d1292e40ebd
Successfully built scapy
Installing 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 = None
Successfully installed scapy-2.4.5
(desk-env) root@desk-mx6ul-lynx:~# pip3 install nmap
Collecting 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 = None
Successfully installed nmap-0.0.1
(desk-env) root@desk-mx6ul-lynx:~# pip3 install ujson
Collecting 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) ... done
Building 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/2e1acde83fd78adc6581984c55442e63d7595711b0b62d8110
Successfully built ujson
Installing 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 = None
Successfully installed ujson-5.1.0
(desk-env) root@desk-mx6ul-lynx:~#

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

(desk-env) root@desk-mx6ul-lynx:~# pip3 list
Package            Version
------------------ ---------
anyio              3.5.0
bottle             0.12.19
certifi            2021.10.8
charset-normalizer 2.0.10
click              8.0.3
contextlib2        21.6.0
fastapi            0.72.0
Flask              2.0.2
idna               3.3
itsdangerous       2.0.1
Jinja2             3.0.3
MarkupSafe         2.0.1
nmap               0.0.1
pip                21.3.1
pydantic           1.9.0
pymodbus           2.5.3
pyserial           3.5
requests           2.27.1
scapy              2.4.5
schema             0.7.5
setuptools         60.5.0
six                1.16.0
sniffio            1.2.0
ssdp               1.1.0
starlette          0.17.1
typing_extensions  4.0.1
ujson              5.1.0
urllib3            1.26.8
Werkzeug           2.0.2
wheel              0.37.1
(desk-env) root@desk-mx6ul-lynx:~# 

import packages[edit | edit source]

Finally, after the installation steps, it is possible to import the packages:

(desk-env) root@desk-mx6ul-lynx:~# python3
Python 3.9.4 (default, Apr  4 2021, 18:23:51) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import os
>>> import time
>>> import ssl
>>> import nmap
>>> import scapy
>>> import serial
>>> import pymodbus
>>> import schema
>>> import ssdp
>>> import requests
>>> import flask
>>> import fastapi
>>> import bottle
>>> import ujson
>>> 
(desk-env) root@desk-mx6ul-lynx:~#