MicroPython with esp8266 and esp32: flashing firmware and using Thonny IDE – 2

Spread the love

MicroPython is a lean implementation of the Python programming language that is optimized for use on microcontrollers and embedded systems. It is designed to be lightweight, efficient, and easy to use, and it provides a way to program microcontrollers using Python code.

MicroPython with esp8266 and esp32: flashing firmware and using Thonny IDE
MicroPython with esp8266 and esp32: flashing firmware and using Thonny IDE

One of the most popular microcontrollers used with MicroPython is the ESP8266 and ESP32, which are low-cost, Wi-Fi enabled microcontrollers that can be used for a wide variety of projects. In this article, we will explore how to get started with MicroPython on the ESP8266 and ESP32 using Thonny, a popular Python IDE.

ESP32 details

I like these devices. It’s very powerful and low cost with an effective value WIFI microcontroller.

You can find It here ESP32 Dev Kit v1 - Selectable - TTGO T-Display 1.14 ESP32 - NodeMCU V3 V2 ESP8266 Lolin32 - NodeMCU ESP-32S - WeMos Lolin32 CP2104 CH340 - ESP32-CAM programmer - ESP32-CAM bundle - ESP32-WROOM-32 - ESP32-S

Specs

Remember that exist a lot of variants of this device. Some have a specified killer function, so this is a generic specs description.

Function Block diagram Espressif esp32 Wi-Fi Bluetooth Microcontroller
Function Block diagram Espressif esp32 Wi-Fi Bluetooth Microcontroller
  • Processors:
    • CPU: Xtensa dual-core (or single-core) 32-bit LX6 microprocessor, operating at 160 or 240 MHz and performing at up to 600 DMIPS
    • Ultra low power (ULP) co-processor
  • Memory: 520 KiB SRAM
  • Wireless connectivity:
    • Wi-Fi: 802.11 b/g/n
    • Bluetooth: v4.2 BR/EDR and BLE (shares the radio with Wi-Fi)
  • Peripheral interfaces:
  • Security:
  • Power management:
    • Internal low-dropout regulator
    • Individual power domain for RTC
    • 5μA deep sleep current
    • Wake up from GPIO interrupt, timer, ADC measurements, capacitive touch sensor interrupt

Pinouts

ESP32 DEV KIT v1

ESP32 DevKIT v4

Esp32 dev kit v4 pinout
Esp32 dev kit v4 pinout

ESP32 WeMos LOLIN32

This device is very powerful, and you can see that there are capacitive touch pins, more than one UART various Analog pins.

How to

You must download drivers for the USB chip, probably you have an esp32 version with cp2102, but exist a variant with ch340 chip.

ESP8266 details

You can find It here WeMos D1 mini - NodeMCU V2 V2.1 V3 - esp01 - esp01 programmer

Specs

Pinouts

Wemos D1 mini

WeMos D1 mini esp8266 pinout mischianti low resolution
WeMos D1 mini esp8266 pinout mischianti low resolution

WeMos D1 mini high-resolution image

NodeMCU V2

NodeMcu v2 pinout low resolution
NodeMcu v2 pinout low resolution

NodeMCU v2.x high-resolution image

NodeMCU v2.1

NodeMcu v2.1 low resolution pinout
NodeMcu v2.1 low resolution pinout

NodeMCU v2.x high-resolution image

NodeMCU v3

NodeMcu v3 low resolution pinout
NodeMcu v3 low resolution pinout

I think that the interesting thing is that It has more than one Hardware Serial, so you can use Serial for communication with devices and Serial1 D4 (only Transmission) to debug.

Drivers

You can download drivers for the USB chips here, check your version of D1 mini and click on drivers.

Here is a more exhaustive list of devices.

An introduction to Thonny IDE

Thonny is a Python IDE that has gained popularity among developers for its simplicity and ease of use. It is a great tool for beginners who are just getting started with Python, as well as for experienced developers who are looking for a streamlined development environment.

One of the features that make Thonny stand out is its MicroPython plugin. This plugin allows developers to use Thonny to write, test, and debug code on microcontrollers running MicroPython, such as the ESP8266 and ESP32.

When working with microcontrollers, developers typically use a serial terminal emulator to interact with the device. With Thonny, however, developers can use a familiar IDE interface to write and debug code on their microcontrollers.

Thonny’s MicroPython plugin provides several useful features for working with MicroPython on microcontrollers. These include:

  1. Device Manager: Thonny’s Device Manager allows developers to connect to their microcontrollers and manage their connections easily. It provides a simple interface for selecting the device type and port and for installing MicroPython firmware onto the device.
  2. Interactive Console: Thonny’s Interactive Console allows developers to interact with their microcontroller in real-time using a Python shell. This can be useful for testing code and debugging issues.
  3. Code Editor: Thonny’s Code Editor provides a full-featured text editor with syntax highlighting, code completion, and debugging support. Developers can write code for their microcontroller directly in the editor and use Thonny’s debugger to identify and fix issues.

By using Thonny with the MicroPython plugin, developers can simplify the development process and improve the reliability of their code. Thonny provides a user-friendly interface for working with microcontrollers, and the MicroPython plugin provides all the tools necessary for writing, testing, and debugging code.

Install Thonny

Thonny is a free and open-source Python IDE that is available for Windows, macOS, and Linux. You can download Thonny from the official website at https://thonny.org.

To simplify the process, we are going to install the version with an integrated version of Python (the first link in the download list).

Select Thonny with already installed version of Python
Select Thonny with already installed version of Python

Follow all the installation process.

Using Thonny to upload the MicroPython firmware on esp32 and esp8266

Download esp32 and esp8266 MicroPython firmware

To install MicroPython on your ESP8266 or ESP32 board, you will need to download the firmware from the official MicroPython website. The firmware is available in binary form for a variety of microcontrollers, including the ESP8266 and ESP32.

Download the firmware

Now on Thonny, go to Tools --> Options...

Thonny interpreter management: select MicroPython version and Serial Port
Thonny interpreter management: select MicroPython version and Serial Port

After that, appear a link in the bottom of the panel.

Thonny link to Install MicroPython firmware on esp32 esp8266
Thonny link to Install MicroPython firmware on esp32 esp8266

A panel for the ESP8266 firmware installer is opened.

Thonny MicroPython firmware installer utility for esp8266 and esp32
Thonny MicroPython firmware installer utility for esp8266 and esp32

You are going to select the Serial port from the combo and the previously downloaded firmware.

Then click on Install, at the end, you will have the MicroPython firmware installed on the device.

First sketch execution

Now we can execute a simple sketch that prints a string in the console.

Here is the sketch:

print("Hello from www.mischianti.org")

And here is the result:

>>> %Run -c $EDITOR_CONTENT
Hello from www.mischianti.org
>>> 
Thonny execute a simple print program
Thonny executes a simple print program

A sketch that interacts with microcontroller peripherals

Now we are going to execute a program that uses the machine package, the library to interact with pins, SPI, i2c ecc.

import machine
import time
pin = machine.Pin(2, machine.Pin.OUT)
while True:
    pin.value(0)
    time.sleep(0.5)
    pin.value(1)
    time.sleep(0.5)


But we have a bad response.

Traceback (most recent cell last):
  File D:/projects/micropython/testesp/main.py", line 1, in <module>
    import machine
ModuleNotFoundError: No module named 'machine'
Thonny execute a blink sketch but error NoModules 'machine'
Thonny executes a blink sketch, but error NoModules ‘machine’

As you can see MicroPython responds that ‘machine’ package is missing.

Install a new MicroPython package

This process should not generally be necessary for machine package, but I am nevertheless providing a potential solution.

To install the package, you must go to Tools --> Manage Packages...

Manage MicroPython packages from Thonny utility
Manage MicroPython packages from Thonny utility

Now search machine, click on It, and then click Install.

Thonny error installing 'machine' 'pycrypto' in MicroPython
Thonny error installing ‘machine’ ‘pycrypto’ in MicroPython

In my case, I get a new error, and I put here the complete log.

install --user machine
Collecting machine
  Using cached machine-0.0.1-py2.py3-none-any.whl (4.2 kB)
Collecting pycrypto
  Using cached pycrypto-2.6.1.tar.gz (446 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: pycrypto
  Building wheel for pycrypto (setup.py): started
  Building wheel for pycrypto (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [179 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-310
      creating build\lib.win-amd64-cpython-310\Crypto
      copying lib\Crypto\pct_warnings.py -> build\lib.win-amd64-cpython-310\Crypto
      copying lib\Crypto\__init__.py -> build\lib.win-amd64-cpython-310\Crypto
      creating build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\hashalgo.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\HMAC.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\MD2.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\MD4.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\MD5.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\RIPEMD.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\SHA.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\SHA224.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\SHA256.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\SHA384.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\SHA512.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      creating build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\AES.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\ARC2.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\ARC4.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\blockalgo.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\Blowfish.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\CAST.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\DES.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\DES3.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\PKCS1_OAEP.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\PKCS1_v1_5.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\XOR.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      creating build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\asn1.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\Counter.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\number.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\py3compat.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\randpool.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\RFC1751.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\winrandom.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\_number_new.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      creating build\lib.win-amd64-cpython-310\Crypto\Random
      copying lib\Crypto\Random\random.py -> build\lib.win-amd64-cpython-310\Crypto\Random
      copying lib\Crypto\Random\_UserFriendlyRNG.py -> build\lib.win-amd64-cpython-310\Crypto\Random
      copying lib\Crypto\Random\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Random
      creating build\lib.win-amd64-cpython-310\Crypto\Random\Fortuna
      copying lib\Crypto\Random\Fortuna\FortunaAccumulator.py -> build\lib.win-amd64-cpython-310\Crypto\Random\Fortuna
      copying lib\Crypto\Random\Fortuna\FortunaGenerator.py -> build\lib.win-amd64-cpython-310\Crypto\Random\Fortuna
      copying lib\Crypto\Random\Fortuna\SHAd256.py -> build\lib.win-amd64-cpython-310\Crypto\Random\Fortuna
      copying lib\Crypto\Random\Fortuna\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Random\Fortuna
      creating build\lib.win-amd64-cpython-310\Crypto\Random\OSRNG
      copying lib\Crypto\Random\OSRNG\fallback.py -> build\lib.win-amd64-cpython-310\Crypto\Random\OSRNG
      copying lib\Crypto\Random\OSRNG\nt.py -> build\lib.win-amd64-cpython-310\Crypto\Random\OSRNG
      copying lib\Crypto\Random\OSRNG\posix.py -> build\lib.win-amd64-cpython-310\Crypto\Random\OSRNG
      copying lib\Crypto\Random\OSRNG\rng_base.py -> build\lib.win-amd64-cpython-310\Crypto\Random\OSRNG
      copying lib\Crypto\Random\OSRNG\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Random\OSRNG
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest
      copying lib\Crypto\SelfTest\st_common.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest
      copying lib\Crypto\SelfTest\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\common.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_AES.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_ARC2.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_ARC4.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_Blowfish.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_CAST.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_DES.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_DES3.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_pkcs1_15.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_pkcs1_oaep.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_XOR.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\common.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_HMAC.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_MD2.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_MD4.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_MD5.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_RIPEMD.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_SHA.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_SHA224.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_SHA256.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_SHA384.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_SHA512.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Protocol
      copying lib\Crypto\SelfTest\Protocol\test_AllOrNothing.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Protocol
      copying lib\Crypto\SelfTest\Protocol\test_chaffing.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Protocol
      copying lib\Crypto\SelfTest\Protocol\test_KDF.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Protocol
      copying lib\Crypto\SelfTest\Protocol\test_rfc1751.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Protocol
      copying lib\Crypto\SelfTest\Protocol\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Protocol
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\PublicKey
      copying lib\Crypto\SelfTest\PublicKey\test_DSA.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\PublicKey
      copying lib\Crypto\SelfTest\PublicKey\test_ElGamal.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\PublicKey
      copying lib\Crypto\SelfTest\PublicKey\test_importKey.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\PublicKey
      copying lib\Crypto\SelfTest\PublicKey\test_RSA.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\PublicKey
      copying lib\Crypto\SelfTest\PublicKey\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\PublicKey
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random
      copying lib\Crypto\SelfTest\Random\test_random.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random
      copying lib\Crypto\SelfTest\Random\test_rpoolcompat.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random
      copying lib\Crypto\SelfTest\Random\test__UserFriendlyRNG.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random
      copying lib\Crypto\SelfTest\Random\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\Fortuna
      copying lib\Crypto\SelfTest\Random\Fortuna\test_FortunaAccumulator.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\Fortuna
      copying lib\Crypto\SelfTest\Random\Fortuna\test_FortunaGenerator.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\Fortuna
      copying lib\Crypto\SelfTest\Random\Fortuna\test_SHAd256.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\Fortuna
      copying lib\Crypto\SelfTest\Random\Fortuna\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\Fortuna
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      copying lib\Crypto\SelfTest\Random\OSRNG\test_fallback.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      copying lib\Crypto\SelfTest\Random\OSRNG\test_generic.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      copying lib\Crypto\SelfTest\Random\OSRNG\test_nt.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      copying lib\Crypto\SelfTest\Random\OSRNG\test_posix.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      copying lib\Crypto\SelfTest\Random\OSRNG\test_winrandom.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      copying lib\Crypto\SelfTest\Random\OSRNG\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Util
      copying lib\Crypto\SelfTest\Util\test_asn1.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Util
      copying lib\Crypto\SelfTest\Util\test_Counter.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Util
      copying lib\Crypto\SelfTest\Util\test_number.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Util
      copying lib\Crypto\SelfTest\Util\test_winrandom.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Util
      copying lib\Crypto\SelfTest\Util\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Util
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Signature
      copying lib\Crypto\SelfTest\Signature\test_pkcs1_15.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Signature
      copying lib\Crypto\SelfTest\Signature\test_pkcs1_pss.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Signature
      copying lib\Crypto\SelfTest\Signature\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Signature
      creating build\lib.win-amd64-cpython-310\Crypto\Protocol
      copying lib\Crypto\Protocol\AllOrNothing.py -> build\lib.win-amd64-cpython-310\Crypto\Protocol
      copying lib\Crypto\Protocol\Chaffing.py -> build\lib.win-amd64-cpython-310\Crypto\Protocol
      copying lib\Crypto\Protocol\KDF.py -> build\lib.win-amd64-cpython-310\Crypto\Protocol
      copying lib\Crypto\Protocol\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Protocol
      creating build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\DSA.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\ElGamal.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\pubkey.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\RSA.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\_DSA.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\_RSA.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\_slowmath.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      creating build\lib.win-amd64-cpython-310\Crypto\Signature
      copying lib\Crypto\Signature\PKCS1_PSS.py -> build\lib.win-amd64-cpython-310\Crypto\Signature
      copying lib\Crypto\Signature\PKCS1_v1_5.py -> build\lib.win-amd64-cpython-310\Crypto\Signature
      copying lib\Crypto\Signature\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Signature
      running build_ext
      warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
      building 'Crypto.Random.OSRNG.winrandom' extension
      creating build\temp.win-amd64-cpython-310
      creating build\temp.win-amd64-cpython-310\Release
      creating build\temp.win-amd64-cpython-310\Release\src
      "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -IC:\Users\renzo\AppData\Local\Programs\Thonny\include -IC:\Users\renzo\AppData\Local\Programs\Thonny\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcsrc/winrand.c /Fobuild\temp.win-amd64-cpython-310\Release\src/winrand.obj
      winrand.c
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(27): error C2061: errore di sintassi: identificatore 'intmax_t'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(28): error C2061: errore di sintassi: identificatore 'rem'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(28): error C2059: errore di sintassi: ';'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(29): error C2059: errore di sintassi: '}'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(31): error C2061: errore di sintassi: identificatore 'imaxdiv_t'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(31): error C2059: errore di sintassi: ';'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(41): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(42): error C2146: errore di sintassi: ')' mancante prima dell'identificatore '_Number'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(42): error C2061: errore di sintassi: identificatore '_Number'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(42): error C2059: errore di sintassi: ';'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(43): error C2059: errore di sintassi: ')'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(46): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(47): error C2146: errore di sintassi: ')' mancante prima dell'identificatore '_Numerator'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(47): error C2061: errore di sintassi: identificatore '_Numerator'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(47): error C2059: errore di sintassi: ';'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(47): error C2059: errore di sintassi: ','
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(49): error C2059: errore di sintassi: ')'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(51): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(57): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(64): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(70): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(77): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(83): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(90): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(96): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pycrypto
  Running setup.py clean for pycrypto
Failed to build pycrypto
Installing collected packages: pycrypto, machine
  Running setup.py install for pycrypto: started
  Running setup.py install for pycrypto: finished with status 'error'
  error: subprocess-exited-with-error
  
  × Running setup.py install for pycrypto did not run successfully.
  │ exit code: 1
  ╰─> [181 lines of output]
      running install
      C:\Users\renzo\AppData\Local\Programs\Thonny\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-310
      creating build\lib.win-amd64-cpython-310\Crypto
      copying lib\Crypto\pct_warnings.py -> build\lib.win-amd64-cpython-310\Crypto
      copying lib\Crypto\__init__.py -> build\lib.win-amd64-cpython-310\Crypto
      creating build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\hashalgo.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\HMAC.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\MD2.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\MD4.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\MD5.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\RIPEMD.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\SHA.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\SHA224.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\SHA256.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\SHA384.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\SHA512.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      copying lib\Crypto\Hash\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Hash
      creating build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\AES.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\ARC2.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\ARC4.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\blockalgo.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\Blowfish.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\CAST.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\DES.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\DES3.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\PKCS1_OAEP.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\PKCS1_v1_5.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\XOR.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      copying lib\Crypto\Cipher\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Cipher
      creating build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\asn1.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\Counter.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\number.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\py3compat.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\randpool.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\RFC1751.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\winrandom.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\_number_new.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      copying lib\Crypto\Util\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Util
      creating build\lib.win-amd64-cpython-310\Crypto\Random
      copying lib\Crypto\Random\random.py -> build\lib.win-amd64-cpython-310\Crypto\Random
      copying lib\Crypto\Random\_UserFriendlyRNG.py -> build\lib.win-amd64-cpython-310\Crypto\Random
      copying lib\Crypto\Random\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Random
      creating build\lib.win-amd64-cpython-310\Crypto\Random\Fortuna
      copying lib\Crypto\Random\Fortuna\FortunaAccumulator.py -> build\lib.win-amd64-cpython-310\Crypto\Random\Fortuna
      copying lib\Crypto\Random\Fortuna\FortunaGenerator.py -> build\lib.win-amd64-cpython-310\Crypto\Random\Fortuna
      copying lib\Crypto\Random\Fortuna\SHAd256.py -> build\lib.win-amd64-cpython-310\Crypto\Random\Fortuna
      copying lib\Crypto\Random\Fortuna\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Random\Fortuna
      creating build\lib.win-amd64-cpython-310\Crypto\Random\OSRNG
      copying lib\Crypto\Random\OSRNG\fallback.py -> build\lib.win-amd64-cpython-310\Crypto\Random\OSRNG
      copying lib\Crypto\Random\OSRNG\nt.py -> build\lib.win-amd64-cpython-310\Crypto\Random\OSRNG
      copying lib\Crypto\Random\OSRNG\posix.py -> build\lib.win-amd64-cpython-310\Crypto\Random\OSRNG
      copying lib\Crypto\Random\OSRNG\rng_base.py -> build\lib.win-amd64-cpython-310\Crypto\Random\OSRNG
      copying lib\Crypto\Random\OSRNG\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Random\OSRNG
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest
      copying lib\Crypto\SelfTest\st_common.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest
      copying lib\Crypto\SelfTest\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\common.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_AES.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_ARC2.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_ARC4.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_Blowfish.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_CAST.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_DES.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_DES3.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_pkcs1_15.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_pkcs1_oaep.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\test_XOR.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      copying lib\Crypto\SelfTest\Cipher\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Cipher
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\common.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_HMAC.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_MD2.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_MD4.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_MD5.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_RIPEMD.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_SHA.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_SHA224.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_SHA256.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_SHA384.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\test_SHA512.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      copying lib\Crypto\SelfTest\Hash\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Hash
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Protocol
      copying lib\Crypto\SelfTest\Protocol\test_AllOrNothing.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Protocol
      copying lib\Crypto\SelfTest\Protocol\test_chaffing.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Protocol
      copying lib\Crypto\SelfTest\Protocol\test_KDF.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Protocol
      copying lib\Crypto\SelfTest\Protocol\test_rfc1751.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Protocol
      copying lib\Crypto\SelfTest\Protocol\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Protocol
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\PublicKey
      copying lib\Crypto\SelfTest\PublicKey\test_DSA.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\PublicKey
      copying lib\Crypto\SelfTest\PublicKey\test_ElGamal.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\PublicKey
      copying lib\Crypto\SelfTest\PublicKey\test_importKey.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\PublicKey
      copying lib\Crypto\SelfTest\PublicKey\test_RSA.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\PublicKey
      copying lib\Crypto\SelfTest\PublicKey\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\PublicKey
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random
      copying lib\Crypto\SelfTest\Random\test_random.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random
      copying lib\Crypto\SelfTest\Random\test_rpoolcompat.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random
      copying lib\Crypto\SelfTest\Random\test__UserFriendlyRNG.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random
      copying lib\Crypto\SelfTest\Random\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\Fortuna
      copying lib\Crypto\SelfTest\Random\Fortuna\test_FortunaAccumulator.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\Fortuna
      copying lib\Crypto\SelfTest\Random\Fortuna\test_FortunaGenerator.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\Fortuna
      copying lib\Crypto\SelfTest\Random\Fortuna\test_SHAd256.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\Fortuna
      copying lib\Crypto\SelfTest\Random\Fortuna\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\Fortuna
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      copying lib\Crypto\SelfTest\Random\OSRNG\test_fallback.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      copying lib\Crypto\SelfTest\Random\OSRNG\test_generic.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      copying lib\Crypto\SelfTest\Random\OSRNG\test_nt.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      copying lib\Crypto\SelfTest\Random\OSRNG\test_posix.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      copying lib\Crypto\SelfTest\Random\OSRNG\test_winrandom.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      copying lib\Crypto\SelfTest\Random\OSRNG\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Random\OSRNG
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Util
      copying lib\Crypto\SelfTest\Util\test_asn1.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Util
      copying lib\Crypto\SelfTest\Util\test_Counter.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Util
      copying lib\Crypto\SelfTest\Util\test_number.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Util
      copying lib\Crypto\SelfTest\Util\test_winrandom.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Util
      copying lib\Crypto\SelfTest\Util\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Util
      creating build\lib.win-amd64-cpython-310\Crypto\SelfTest\Signature
      copying lib\Crypto\SelfTest\Signature\test_pkcs1_15.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Signature
      copying lib\Crypto\SelfTest\Signature\test_pkcs1_pss.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Signature
      copying lib\Crypto\SelfTest\Signature\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\SelfTest\Signature
      creating build\lib.win-amd64-cpython-310\Crypto\Protocol
      copying lib\Crypto\Protocol\AllOrNothing.py -> build\lib.win-amd64-cpython-310\Crypto\Protocol
      copying lib\Crypto\Protocol\Chaffing.py -> build\lib.win-amd64-cpython-310\Crypto\Protocol
      copying lib\Crypto\Protocol\KDF.py -> build\lib.win-amd64-cpython-310\Crypto\Protocol
      copying lib\Crypto\Protocol\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Protocol
      creating build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\DSA.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\ElGamal.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\pubkey.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\RSA.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\_DSA.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\_RSA.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\_slowmath.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      copying lib\Crypto\PublicKey\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\PublicKey
      creating build\lib.win-amd64-cpython-310\Crypto\Signature
      copying lib\Crypto\Signature\PKCS1_PSS.py -> build\lib.win-amd64-cpython-310\Crypto\Signature
      copying lib\Crypto\Signature\PKCS1_v1_5.py -> build\lib.win-amd64-cpython-310\Crypto\Signature
      copying lib\Crypto\Signature\__init__.py -> build\lib.win-amd64-cpython-310\Crypto\Signature
      running build_ext
      warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
      building 'Crypto.Random.OSRNG.winrandom' extension
      creating build\temp.win-amd64-cpython-310
      creating build\temp.win-amd64-cpython-310\Release
      creating build\temp.win-amd64-cpython-310\Release\src
      "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -Isrc/ -Isrc/inc-msvc/ -IC:\Users\renzo\AppData\Local\Programs\Thonny\include -IC:\Users\renzo\AppData\Local\Programs\Thonny\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcsrc/winrand.c /Fobuild\temp.win-amd64-cpython-310\Release\src/winrand.obj
      winrand.c
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(27): error C2061: errore di sintassi: identificatore 'intmax_t'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(28): error C2061: errore di sintassi: identificatore 'rem'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(28): error C2059: errore di sintassi: ';'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(29): error C2059: errore di sintassi: '}'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(31): error C2061: errore di sintassi: identificatore 'imaxdiv_t'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(31): error C2059: errore di sintassi: ';'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(41): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(42): error C2146: errore di sintassi: ')' mancante prima dell'identificatore '_Number'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(42): error C2061: errore di sintassi: identificatore '_Number'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(42): error C2059: errore di sintassi: ';'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(43): error C2059: errore di sintassi: ')'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(46): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(47): error C2146: errore di sintassi: ')' mancante prima dell'identificatore '_Numerator'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(47): error C2061: errore di sintassi: identificatore '_Numerator'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(47): error C2059: errore di sintassi: ';'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(47): error C2059: errore di sintassi: ','
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(49): error C2059: errore di sintassi: ')'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(51): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(57): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(64): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(70): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(77): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(83): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(90): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\inttypes.h(96): error C2143: errore di sintassi: '{' mancante prima di '__cdecl'
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> pycrypto

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
Process returned with code 1


Fix machine/pycrypt installation package

A solution for this problem is this:

From the log, you can get the path of Microsoft Visual Studio BuildTools, and then execute these commands:

cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build"
vcvarsall.bat x86_amd64
cd %VCINSTALLDIR%
for /R %f in (*stdint.h) do set CL=-FI"%f"

Get the installation folder from Tools --> Open Thonny Program Folder... then go to the script folder:

cd C:\Users\renzo\AppData\Local\Programs\Thonny\Scripts

Then retry to install the machine package.

Microsoft Windows [Version 10.0.19045.2604]
(c) Microsoft Corporation. All rights reserved.

C:\Users\renzo\AppData\Local\Programs\Thonny\Scripts>cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build"

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build>vcvarsall.bat x86_amd64
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x86_x64'

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build>cd %VCINSTALLDIR%

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC>for /R %f in (*stdint.h) do set CL=-FI"%f"

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC>set CL=-FI"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\include\stdint.h"

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC>cd C:\Users\renzo\AppData\Local\Programs\Thonny\Scripts

C:\Users\renzo\AppData\Local\Programs\Thonny\Scripts>pip install machine
Collecting machine
  Using cached machine-0.0.1-py2.py3-none-any.whl (4.2 kB)
Collecting pycrypto
  Using cached pycrypto-2.6.1.tar.gz (446 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pycrypto
  Building wheel for pycrypto (setup.py) ... done
  Created wheel for pycrypto: filename=pycrypto-2.6.1-cp310-cp310-win_amd64.whl size=518524 sha256=fa3f3ff0eca2465a42ea648cc7381ac5246ef22ec38cf3d0c4a9a0289ad43603
  Stored in directory: c:\users\renzo\appdata\local\pip\cache\wheels\a0\d7\84\7efd0ece2c2dd3cb2cca129cbc772eaf7c898f604e9d040b7b
Successfully built pycrypto
Installing collected packages: pycrypto, machine
  WARNING: The script sample.exe is installed in 'C:\Users\renzo\AppData\Local\Programs\Thonny\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed machine-0.0.1 pycrypto-2.6.1

[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: C:\Users\renzo\AppData\Local\Programs\Thonny\python.exe -m pip install --upgrade pip

C:\Users\renzo\AppData\Local\Programs\Thonny\Scripts>

Now we retry the execution of the blink sketch. And finally, work.

Thonny executes the blink program
Thonny executes the blink program

Here the esp8266.

WeMos d1 mini (esp8266): led light
WeMos d1 mini (esp8266): led light

Thanks

Mastering esp8266 programming with MicroPython

  1. MicroPython with esp8266 and esp32: flashing firmware and using standard tools
  2. MicroPython with esp8266 and esp32: flashing firmware and using Thonny IDE
  3. MicroPython with esp8266 and esp32: flashing firmware and using PyCharm IDE

Mastering ESP32 programming with MicroPython

  1. MicroPython with esp8266 and esp32: flashing firmware and using standard tools
  2. MicroPython with esp8266 and esp32: flashing firmware and using Thonny IDE
  3. MicroPython with esp8266 and esp32: flashing firmware and using PyCharm IDE

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *