Just to close the loop for anyone from the future...
Here's the steps I took to resolve this:
- Uninstall / Cleanup / Restore to macos Mojave default python installation. (Which is v2.7.16 as noted above.) This was a pretty intensive step. The short breadcrumb for anyone else:
Dont touch the mac system python installs located at:
helpful stack overflow post for uninstalling python
But in the end, from what I could find Mojave doesn't include pip by default, and easy_install is depreciated so we had to go to step 2.
brew install python Today in Dec 2020 this will install 3.9.0. ((Python 2.7 has been long depreciated))[Also note pip is currently installed with this version of python]
- At this point if you type
python --version you will still get:
- While reading the ESP-IDF toolchain instructions, I noticed the following command:
ln -s /usr/local/bin/python3 /usr/local/bin/python
This setup a symlink to the python3 symlink also installed by brew. (Seems kind of hacky, but technically works...) I also had to do:
ln -s /usr/local/bin/pip3 /usr/local/bin/pip which cleaned up any remaining issues making pip work. (Biggest issue being me forgetting to type pip3)
- After restarting my terminal, running
python --version I now get:
- With my new python env working as expected, I fired up ardunio IDE and one of the Core2 examples, and went to verify to see if my issues went away... And I still had the issues above in my original post.
6b. At this point I tried a ton of other things, most notably redoing everything by installing pyenv and trying to set the global env to 3.9, but none of those steps worked...
- I went back through the troubleshooting steps above, had the expected correct outcomes. Even ran the esp-tools.py directly and didnt have any issues importing serial or anything else.
- I believe the actual issue is the first line in the esp-tools.py:
Which I believe is what is forcing the ardunio IDE to use the default MacOS python version. (See note in #1 about this being the protected default python that we shouldnt touch.)
- Just as a test, I changed that line to be:
Once I reopened Ardunio, this worked and verified without any issues.
- However, I feared that if I ever updated the board definitions I would forget about this change and it would all break again. So I followed @lydericc instructions above. (Thank you!) You really shouldnt do this, but it's the only way to make it "work" with everything else out of the box. Specifically the following line (Step 2 in the post above):
sudo pip3 install --target /Library/Python/2.7/site-packages pyserial
This installed the required serial module and fixed the remaining issues.
I'm not sure I like the solution, but it is the only thing that has made it work. The "correct" fix would be to have esp-tool.py use the installed default python version instead of the specific one installed at /usr/bin.
Finally, as with all things in life, there is already an xkcd for this: https://xkcd.com/1987/
Maybe I'll open an issue with the esp-tool or Ardunio IDE and see what happens, but I dont believe this has anything to do with M5stack tools. Thanks for all who helped! (@Zontex & @lydericc )