A good run down on how to install support for ESP32 boards into the Arduino IDE can be found here – https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/
When I first read about the ESP32 the idea of a WiFi ready Arduino was really exciting. Naturally, I was straight onto eBay to buy some. A couple of years later, when I finally got round to playing with them, I ran into a problem that seems to be quite common. When I tried to compile and upload the blink example sketch (https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink) I received the error “/home/thegeek/.arduino15/packages/esp32/tools/esptool_py/3.0.0/esptool.py”, line 38, in import serial Import Error: No module named serial”
After some googling it became apparent that lots of people run into the same problem (not to mention that I had to add #define LED_BUILTIN 2 to the set_up() code) and there really are some wild and wonderful “solutions” to the problem. The easiest way to solve this issue is simply to load the module that Python is asking for.
Some people seem to be falling down because they have more than one version of Python on their computers and don’t have the pyserial module installed on the one that the Arduino IDE is trying to use. In my case the Arduino IDE was trying to use Python 2. On most systems Python 2 is started using the “python” command and Python 3 with the “python3” command and we can test to see if pyserial is installed by trying to import it using Python’s immediate mode, this is illustrated in the following screen shot and in my case you can see that I don’t have pyserial installed on either version.
Usually you would use pip to install Python elements that you need but in this case (and I don’t know Python/pip well enough to know why) pip tells us that pyserial is already there.
The easiest and quickest way around this is to install pyserial from source. To do this we need to download it from its github repository. From your home directory, issue the following commands –
git clone https://github.com/pyserial/pyserial
Next, cd into the pyserial directory and issue the command sudo python setup.py install. You have to use sudo in order to allow setup.py to update the python system folders.
If everything runs correctly you’ll see something like this –
Now you can perform the immediate mode test again and see that pyserial has successfully installed and is available. You can also remove the install files with rm -rf pyserial (after you have cd .. out of the pyserial directory)
You should now be able to upload sketches to your ESP32.