No module named 'serial'. Linux Mint

I have a problem getting my esp32 wroom recognised in the Arduino IDE , as in a serial port error.

No matter what sketch I load into the IDE ,and compile, it returns the same error message about no module named serial. There is nothing in any of the sketches I tried that says serial.
When I list my ports with /dmesg | grep tty, I get
rob@rob-hp:~$ dmesg | grep tty
[ 0.095717] printk: legacy console [tty0] enabled
[ 0.416881] 00:03: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[ 0.440076] 0000:00:16.3: ttyS4 at I/O 0x3060 (irq = 19, base_baud = 115200) is a 16550A
, which are showing in the IDE. But when I check ,'get board info' it returns:
Native serial port, can't obtain info.

Thanks

Does the port work with other devices? If so you may have a bad board.

I tried 2 esp32 wroom's and neither were recognised. I then tried an Arduino Uno, and that was recognised on ttyACM0.

Maybe both ep32's are bad then?

Hi @avalon66.

The Linux version of the ESP32 boards platform uses a Python script named esptool when compiling sketches. That esptool script has a dependency on the pyserial Python package. The "No module named 'serial'" error occurs because that package dependency is not installed on your computer.

We are accustomed to all the dependencies of Arduino boards platforms being automatically installed along with the platform by the Arduino "Boards Manager", but the ESP32 platform developers didn't make their project that way. You are expected to manually install this pyserial Python package if you don't have it installed already. So the solution to the error is to use pip to install the pyserial package.

Try this:

  1. Open a command line terminal on your computer.
  2. Type the following command:
    python3 -m pip install pyserial
    
  3. Press the Enter key.
  4. Wait for the command to complete successfully.

Now try compiling your sketch again. Hopefully the "No module named 'serial'" error will no longer occur.

Thank you that did the trick. I would never have know that , but for your reply.

Just for information the 2 ep32 boards I have are not recognised? but and |Arduino Uno is

I'm glad we have solved the "no module named serial" problem at least. That is progress!

Make sure the USB cable is completely plugged into both the Arduino board and the PC.

If that doesn't help, you may have a damaged/defective or charge-only USB cable. Try a different cable.

Either of the above can result in the power connections being made (and thus LEDs lit on the board), but no data connections (and thus no port for the board).

Thank ,the cable was the problem, and both esp32's are now recognised

You are welcome. I'm glad everything is working now.

Regards, Per

I have the same issue. I just moved to Linux Mint from XUbuntu where it was working. I know the serial connection is working because the sketch I uploaded while on Ubuntu is still on the ESP32 and I can control it via the USB and serial monitor..

python --version
Python 3.12.3

but running python3 -m pip install pyserial gives me this:

$ python3 -m pip install pyserial
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.

See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

I tried this: ARDUINO IDE - 'No module named serial' - Linux Mint Forums but have nothing in
/usr/local/lib/python3.12/dist-packages/

I kind of like this Mint so far - but for my inability to use Arduino with my ESP32s.

I am hoping there is a simple solution.

sudo apt install python3-serial
1 Like

well now I am really embarrassed. I could have sworn I tried that but clearly not as it "just worked".

:face_with_open_eyes_and_hand_over_mouth:

thank you