With the arduino 1.8.13 IDE, I built a sketch and while flashing it to the esp32 chip, I get the following error:
AttributeError: 'Serial' object has no attribute 'dtr'
It found out that esptool is running on python2, not python3. And I guess there is no pyserial package for python2. I tried to install pyserial for python2, but there is no pip for python2, only pip3. I wonder why esp32 needs python2. With esp8266 modules, all works fine.
Can I switch arduino to python3 and how?
pert
October 17, 2020, 7:46pm
2
This comment I found in the ESP32 issue tracker indicates the opposite:
opened 04:03PM - 01 Mar 18 UTC
closed 03:11PM - 28 Jul 18 UTC
### Hardware:
Board: ?ESP32 Dev Module?
Core Installation/update date: … ?11/jul/2017?
IDE name: ?Arduino IDE? ?Platform.io? ?IDF component?
Flash Frequency: ?40Mhz?
Upload Speed: ?115200?
### Description:
For a few days I have been installing the arduino-esp32 development enviroment again and again. But failed all the time. The esp32 module could been found in the arduino. But when compile and upload , it failed... The error message is as below:
Archiving built core (caching) in: C:\DOCUME~1\dell\LOCALS~1\Temp\arduino_cache_197603\core\core_espressif_esp32_esp32_FlashMode_qio,FlashFreq_80,FlashSize_4M,UploadSpeed_921600,DebugLevel_none_2b738b201fc88a468b2acb947ad43f23.a
Traceback (most recent call last):
File "esptool.py", line 25, in <module>
File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
# executes the module code. This is crucial because the module
File "site-packages\serial\__init__.py", line 27, in <module>
File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
# executes the module code. This is crucial because the module
File "site-packages\serial\serialwin32.py", line 15, in <module>
File "c:\python27\Lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
# executes the module code. This is crucial because the module
File "site-packages\serial\win32.py", line 182, in <module>
File "ctypes\__init__.py", line 375, in __getattr__
File "ctypes\__init__.py", line 380, in __getitem__
AttributeError: function 'CancelIoEx' not found
Failed to execute script esptool
exit status -1
My PC is windows xp sp3, python use python 2.7. I have tried the following methods:
----try python2.7.10 and then 2.7.12
-----change pyserial from 2.7 to pyserial3.0.1;
-----change arduino from version 1.8.2 to 1.8.5;
-----change the directory from" C:\Documents and Settings\dell\My Documents\Arduino\hardware \espressif\esp32" to "C:\Program Files\Arduino\hardware\espressif\esp32"
All the time it failed. This trouble me for a few days. Anyone know how to resolve this problem, thanks very much!
The new version requires pyserial 3, and with 2.7 it will produce an error like
AttributeError: 'Serial' object has no attribute 'dtr'
So I think the situation is that esptool requires Python 3, but for some reason Python 2 is being used.
Which operating system are you using?
It's not the opposite, it is the same. I use Ubuntu 20.04. For esp8266, python3 is used, but for esp32, python2 is used.