PySerial and EspTools Directory Error

Hi. So, apparently. I'm new to this Arduino community.
And there's an error while I'm trying to upload a sketch that I made.
By sketch, I mean any sketch. I can't seem to upload them into my
NodeMCU 1.0 ESP8266 Board for some reason. It gave me this error,

pyserial or esptool directories not found next to this upload.py tool.
An error occurred while uploading the sketch

Full error message :

Arduino: 1.8.13 (Mac OS X), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

Executable segment sizes:
IROM   : 232856          - code in flash         (default or ICACHE_FLASH_ATTR) 
IRAM   : 26888   / 32768 - code in IRAM          (ICACHE_RAM_ATTR, ISRs...) 
DATA   : 1248  )         - initialized variables (global, static) in RAM/HEAP 
RODATA : 728   ) / 81920 - constants             (global, static) in RAM/HEAP 
BSS    : 24928 )         - zeroed variables      (global, static) in RAM/HEAP 
Sketch uses 261720 bytes (25%) of program storage space. Maximum is 1044464 bytes.
Global variables use 26904 bytes (32%) of dynamic memory, leaving 55016 bytes for local variables. Maximum is 81920 bytes.
pyserial or esptool directories not found next to this upload.py tool.
An error occurred while uploading the sketch


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

and yes, I did use my MacBook using macOS cause that's the
only laptop that I have. Plus, I also tried the following :

    • Reinstall Arduino
    • Reinstalling Python
    • Installed Python 3
    • Installed module of pyserial and esptools using Command Line
      And yet, for some reason it still won't work.
      Is there anything that I could do?. My friend can't help
      me that much.

Every response is appreciated.
Thanks!.

Nobody? Nothing? Ran into the same problem and can't find a solution (except I am running ESP8266EX).

OK, I don't remember how did I sort it out last time, but now I have ran into the same problem again when I made a fresh new install of Big Sur. I am still not able to send the compiled sketch into the ESP through the ArduinoIDE, however I have managed to get it work with the help of external tools completely independent of Arduino software. I did use makeEspArduino tool from Peter Lerup (plerup). At the beginning I was running into the same issue, however I have soon discovered it is very important how you install the Python libraries (if is it as a root user or a regular user). Basically it means, that the problem is in the rights. ArduinoIDE is running processes under the different user than it did install libraries. Till now I am still not able to get it work over ArduinoIDE, but fortunately solution from Peter works well. It is a few more steps to do before upload can be performed, it is not as streamlined as ArduinoIDE, but IT IS WORKING! I am now thinking about letting the ArduinoIDE be as it is, don't worrying about it, forget it and use different approaches where I have way more control over what and how is being done than rely solely on something what is doing it's stuff on the background and spits error after error on me. The worst thing is that no-one even replied on this issue for more than two months now. How are you supposed to work with that?

I ran into this issue on Big Sur as well. It looks like the upload tool doesn't currently work out-of-the-box. Specifically, upload.py uses esptool which uses pyserial which is not fully functional on Big Sur.

The workaround is to edit ~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools/esptool/esptool.py and comment out a block of code by adding # to the start of each line:

#try:
#    import serial.tools.list_ports as list_ports
#except ImportError:
#    print("The installed version (%s) of pyserial appears to be too old for esptool.py (Python interpreter %s). "
#          "Check the README for installation instructions." % (sys.VERSION, sys.executable))
#    raise

Anyway, hope this helps someone else who searches for this issue and arrives at this thread.

2 Likes

I updated my mac to macOS 11.0.1 Big Sur today and found the same problem.
Instead of commenting the lines that flszen mentioned I fixed the source of the problem.

Context

  • Arduino IDE version: 1.8.13
  • esp8266 Core version: 2.7.4

My workaround is as follows:

1.- Open ~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools/pyserial/serial/tools/list_ports_osx.py
2.- Comment out lines 29 and 30 and append these lines:
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')

The code should look like this:

#iokit = ctypes.cdll.LoadLibrary(ctypes.util.find_library('IOKit'))
#cf = ctypes.cdll.LoadLibrary(ctypes.util.find_library('CoreFoundation'))
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')

This is the same fix that the developers of pyserial made (Latest version of the file here) to fix this issue but the esp8266 core uses a 2 year old version of pyserial, so until they update the library this will still be an issue.

11 Likes

I found this error like topic, pls help to fix it. I just update latest os mac version to Big Sur.
This version make me really Big surprise lol

juanssl:
I updated my mac to macOS 11.0.1 Big Sur today and found the same problem.
Instead of commenting the lines that flszen mentioned I fixed the source of the problem.

Context

  • Arduino IDE version: 1.8.13
  • esp8266 Core version: 2.7.4

My workaround is as follows:

1.- Open ~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools/pyserial/serial/tools/list_ports_osx.py
2.- Comment out lines 29 and 30 and append these lines:
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')

The code should look like this:

#iokit = ctypes.cdll.LoadLibrary(ctypes.util.find_library('IOKit'))

#cf = ctypes.cdll.LoadLibrary(ctypes.util.find_library('CoreFoundation'))
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')




This is the same fix that the developers of pyserial made ([Latest version of the file here](https://github.com/pyserial/pyserial/blob/master/serial/tools/list_ports_osx.py)) to fix this issue but the esp8266 core uses a 2 year old version of pyserial, so until they update the library this will still be an issue.

juanssl:
I updated my mac to macOS 11.0.1 Big Sur today and found the same problem.
Instead of commenting the lines that flszen mentioned I fixed the source of the problem.

Context

  • Arduino IDE version: 1.8.13
  • esp8266 Core version: 2.7.4

My workaround is as follows:

1.- Open ~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools/pyserial/serial/tools/list_ports_osx.py
2.- Comment out lines 29 and 30 and append these lines:
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')

The code should look like this:

#iokit = ctypes.cdll.LoadLibrary(ctypes.util.find_library('IOKit'))

#cf = ctypes.cdll.LoadLibrary(ctypes.util.find_library('CoreFoundation'))
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')




This is the same fix that the developers of pyserial made ([Latest version of the file here](https://github.com/pyserial/pyserial/blob/master/serial/tools/list_ports_osx.py)) to fix this issue but the esp8266 core uses a 2 year old version of pyserial, so until they update the library this will still be an issue.

Wowwww It's work for me....
thank you so much.

3 Likes

juanssl:
I updated my mac to macOS 11.0.1 Big Sur today and found the same problem.
Instead of commenting the lines that flszen mentioned I fixed the source of the problem.

Context

  • Arduino IDE version: 1.8.13
  • esp8266 Core version: 2.7.4

My workaround is as follows:

1.- Open ~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools/pyserial/serial/tools/list_ports_osx.py
2.- Comment out lines 29 and 30 and append these lines:
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')

The code should look like this:

#iokit = ctypes.cdll.LoadLibrary(ctypes.util.find_library('IOKit'))

#cf = ctypes.cdll.LoadLibrary(ctypes.util.find_library('CoreFoundation'))
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')




This is the same fix that the developers of pyserial made ([Latest version of the file here](https://github.com/pyserial/pyserial/blob/master/serial/tools/list_ports_osx.py)) to fix this issue but the esp8266 core uses a 2 year old version of pyserial, so until they update the library this will still be an issue.

IT worked! Thanks man.

Juanssl, you get a Karma point for that, I spent hours trying t figure out what was going on! Thank you.

1 Like

BigSur broke a LOT of things

Arduino engineers became aware of the larger picture this morning but don't expect any quick fix for SNAPples mistake.

If bigsur can be rolled back you may want to try that ?

Also the SEARCH for "big sur" on this forum may bring you a couple of work arounds worth playing with.

Why does Apple keep doing this to us? I switched from windows 10 years ago and it was great up until that last few years when this untested stuff is constantly foisted on us, the trusting public. I think I will hold off on these "upgrades" until at least 6 months have gone by.

juanssl:
My workaround is as follows:

1.- Open ~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools/pyserial/serial/tools/list_ports_osx.py
2.- Comment out lines 29 and 30 and append these lines:
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')

The code should look like this:

#iokit = ctypes.cdll.LoadLibrary(ctypes.util.find_library('IOKit'))

#cf = ctypes.cdll.LoadLibrary(ctypes.util.find_library('CoreFoundation'))
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')




Many thanks for that workaround, it works for me too :)

Can confirm that the @juanssl fix worked for me; 11.0.1 on a 2017 4-Thunderbolt MacBook 13".

Karma added – THANK YOU!

juanssl:
I updated my mac to macOS 11.0.1 Big Sur today and found the same problem.
Instead of commenting the lines that flszen mentioned I fixed the source of the problem.

Context

  • Arduino IDE version: 1.8.13
  • esp8266 Core version: 2.7.4

My workaround is as follows:

1.- Open ~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools/pyserial/serial/tools/list_ports_osx.py
2.- Comment out lines 29 and 30 and append these lines:
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')

The code should look like this:

#iokit = ctypes.cdll.LoadLibrary(ctypes.util.find_library('IOKit'))

#cf = ctypes.cdll.LoadLibrary(ctypes.util.find_library('CoreFoundation'))
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')




This is the same fix that the developers of pyserial made ([Latest version of the file here](https://github.com/pyserial/pyserial/blob/master/serial/tools/list_ports_osx.py)) to fix this issue but the esp8266 core uses a 2 year old version of pyserial, so until they update the library this will still be an issue.

works perfectly! Thank you so much!

Thanks!

juanssl:
I updated my mac to macOS 11.0.1 Big Sur today and found the same problem.
Instead of commenting the lines that flszen mentioned I fixed the source of the problem.

Context

  • Arduino IDE version: 1.8.13
  • esp8266 Core version: 2.7.4

My workaround is as follows:

1.- Open ~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.7.4/tools/pyserial/serial/tools/list_ports_osx.py
2.- Comment out lines 29 and 30 and append these lines:
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')

The code should look like this:

#iokit = ctypes.cdll.LoadLibrary(ctypes.util.find_library('IOKit'))

#cf = ctypes.cdll.LoadLibrary(ctypes.util.find_library('CoreFoundation'))
iokit = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/IOKit.framework/IOKit')
cf = ctypes.cdll.LoadLibrary('/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation')




This is the same fix that the developers of pyserial made ([Latest version of the file here](https://github.com/pyserial/pyserial/blob/master/serial/tools/list_ports_osx.py)) to fix this issue but the esp8266 core uses a 2 year old version of pyserial, so until they update the library this will still be an issue.

It work, thank you.

  • WeMos D1 R1 (ESP8266)
  • Arduino 1.8.13
  • Big Sur 11.0.1

Still no success for me. No matter what I do, I still get that same error.
To be fair, I'm basically a smart monkey at coding.

works fine for me too... :smiley:
What would all these newbies like me do without your support
Thanks a lot...

Good afternoon, I have this issue with pyserial and esptools and have tried the workarounds above both of which don't work for me. Has anything changed in the last 3 weeks or so that I can try. I'm getting very frustrated with the whole thing when not so long ago everything worked perfectly.

Thanks in anticipation of any help.

@JollyGreyFlyer

Could you take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Not all situations are exactly the same so DETAILS may make a large difference in the responses.