espressif / esptool

Espressif SoC serial bootloader utility
https://docs.espressif.com/projects/esptool
GNU General Public License v2.0
5.6k stars 1.39k forks source link

[MacOS] AttributeError: module 'serial' has no attribute 'serialutil' (ESPTOOL-920) #1007

Closed chipweinberger closed 2 months ago

chipweinberger commented 2 months ago

Operating System

macOS 14.6.1

Esptool Version

esptool.py v4.7.0

Python Version

3.12

Full Esptool Command Line that Was Run

/Volumes/User/MBP-Google-Drive/jamcorder/firmware/.espressif/python_env/idf5.1_py3.12_env/bin/python /Volumes/User/MBP-Google-Drive/jamcorder/firmware/esp-idf/components/esptool_py/esptool/esptool.py --port /dev/cu.usbmodem2101 --baud 921600 --before default_reset --after no_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 8MB --force 0x0 /Volumes/User/MBP-Google-Drive/jamcorder/firmware/jamcorder-firmware/jfwm/build/bootloader/bootloader.bin.enc 0xf000 /Volumes/User/MBP-Google-Drive/jamcorder/firmware/jamcorder-firmware/jfwm/build/partition_table/partition-table.bin.enc 0x10000 /Volumes/User/MBP-Google-Drive/jamcorder/firmware/jamcorder-firmware/jfwm/build/ota_data_initial.bin.enc 0x300000 /Volumes/User/MBP-Google-Drive/jamcorder/firmware/jamcorder-firmware/jfwm/build/jJfwmApp.bin.enc 0xe0000 /Volumes/User/MBP-Google-Drive/jamcorder/firmware/jamcorder-firmware/jfu/build/jJfuApp.bin.enc 0x25000 /Volumes/User/MBP-Google-Drive/jamcorder/firmware/jamcorder-firmware/jfu/build/jOtaAesKey.bin.enc

Esptool Output

/Volumes/User/MBP-Google-Drive/jamcorder/firmware/.espressif/python_env/idf5.1_py3.12_env/bin/python /Volumes/User/MBP-Google-Drive/jamcorder/firmware/esp-idf/components/esptool_py/esptool/esptool.py --port /dev/cu.usbmodem2101 --baud 921600 --before default_reset --after no_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 8MB --force 0x0 /Volumes/User/MBP-Google-Drive/jamcorder/firmware/jamcorder-firmware/jfwm/build/bootloader/bootloader.bin.enc 0xf000 /Volumes/User/MBP-Google-Drive/jamcorder/firmware/jamcorder-firmware/jfwm/build/partition_table/partition-table.bin.enc 0x10000 /Volumes/User/MBP-Google-Drive/jamcorder/firmware/jamcorder-firmware/jfwm/build/ota_data_initial.bin.enc 0x300000 /Volumes/User/MBP-Google-Drive/jamcorder/firmware/jamcorder-firmware/jfwm/build/jJfwmApp.bin.enc 0xe0000 /Volumes/User/MBP-Google-Drive/jamcorder/firmware/jamcorder-firmware/jfu/build/jJfuApp.bin.enc 0x25000 /Volumes/User/MBP-Google-Drive/jamcorder/firmware/jamcorder-firmware/jfu/build/jOtaAesKey.bin.enc

esptool.py v4.7.0
Serial port /dev/cu.usbmodem2101
Traceback (most recent call last):
  File "/Volumes/User/MBP-Google-Drive/jamcorder/firmware/.espressif/python_env/idf5.1_py3.12_env/lib/python3.12/site-packages/esptool/loader.py", line 303, in __init__
    self._port = serial.serial_for_url(port)
                 ^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'serial' has no attribute 'serial_for_url'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Volumes/User/MBP-Google-Drive/jamcorder/firmware/.espressif/python_env/idf5.1_py3.12_env/lib/python3.12/site-packages/esptool/__init__.py", line 1139, in _main
    main()
  File "/Volumes/User/MBP-Google-Drive/jamcorder/firmware/.espressif/python_env/idf5.1_py3.12_env/lib/python3.12/site-packages/esptool/__init__.py", line 712, in main
    esp = esp or get_default_connected_device(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/User/MBP-Google-Drive/jamcorder/firmware/.espressif/python_env/idf5.1_py3.12_env/lib/python3.12/site-packages/esptool/__init__.py", line 1018, in get_default_connected_device
    _esp = detect_chip(
           ^^^^^^^^^^^^
  File "/Volumes/User/MBP-Google-Drive/jamcorder/firmware/.espressif/python_env/idf5.1_py3.12_env/lib/python3.12/site-packages/esptool/cmds.py", line 94, in detect_chip
    detect_port = ESPLoader(port, baud, trace_enabled=trace_enabled)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Volumes/User/MBP-Google-Drive/jamcorder/firmware/.espressif/python_env/idf5.1_py3.12_env/lib/python3.12/site-packages/esptool/loader.py", line 304, in __init__
    except serial.serialutil.SerialException as e:
           ^^^^^^^^^^^^^^^^^
AttributeError: module 'serial' has no attribute 'serialutil'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/Volumes/User/MBP-Google-Drive/jamcorder/firmware/.espressif/python_env/idf5.1_py3.12_env/lib/python3.12/site-packages/esptool/__main__.py", line 9, in <module>
    esptool._main()
  File "/Volumes/User/MBP-Google-Drive/jamcorder/firmware/.espressif/python_env/idf5.1_py3.12_env/lib/python3.12/site-packages/esptool/__init__.py", line 1143, in _main
    except serial.serialutil.SerialException as e:
           ^^^^^^^^^^^^^^^^^
AttributeError: module 'serial' has no attribute 'serialutil'

What is the Expected Behaviour?

to flash the firmware

More Information

  1. I recently installed macOS 14.6.1, previously 14.5.0
  2. this updated python from 3.11 to 3.12
  3. everything seemed broken. here are some of the errors i was getting & fixing by reinstalling things.
    ImportError: cannot import name 'ESPLoader' from 'esptool' (/Volumes/User/MBP-Google-Drive/jamcorder/firmware/esp-idf/components/esptool_py/esptool/esptool.py)
    ModuleNotFoundError: No module named 'esptool.cmds'; 'esptool' is not a package

but now i seem stuck.

AttributeError: module 'serial' has no attribute 'serialutil'

Other Steps to Reproduce

No response

chipweinberger commented 2 months ago

running these commands seems to have fixed it

pip uninstall pyserial
pip install pyserial