MAC M1 ESP32 CAM environment construction notes

Recently, I installed ESP32 CAM under my M1 MAC, which is very useful. I tossed about when building the environment. Here is a record, hoping to provide some clues to students with similar situations.


1. For the big sur system of mac, you'd better install python 3.9.1 or above (I use 3.9.6), and install Python 3.0 first 9.1, and then install IDF. Python can download the installation package. The download address of the installation package is: https://npm.taobao.org/mirrors/python
The installation directory is usually / usr / local / bin / python3 nine
2. For the development environment IDF of git clone ESP32, note that the zip package downloaded directly cannot be used. Git address: https://github.com/espressif/esp-idf , clone address: https://github.com/espressif/esp-idf.git
3. git downloads the latest ESP 32 CAM component package esp32 camera. The esp32 camera in anxinco's example is too old and does not support mac's big sur system. After downloading, overwrite the new esp32 camera directory with the original esp32 camera directory of anxinco's project: esp32/cam/components /, clone address: https://github.com/espressif/esp32-camera
4. Set the default python version. The mac does not allow you to change the / usr/bin/python file (this file is connected to the default python 2.7 of the mac system and cannot be used, deleted or changed. You can use an alias):
   vi ~/.bash_profile
Add: alias python = "/ usr / local / bin / Python 3.9"
After saving and exiting, execute source ~ / bash_ Profile makes the configuration effective
4. Enter the IDF directory and run/ install.sh, it will automatically detect the use of python 3 9. Generally, install IDF's python environment idf4 smoothly 4_ py3. 9_ Env, the installation directory is generally:
   /Users/songfengchen/.espressif/python_env/idf4.4_py3.9_env /, where songfengchen is the current mac user name
5. Edit bash again_ Profile, specify Python as the python file in the idf environment, otherwise execute the next step/ export.sh may fail, prompting that Python is not a file in the python environment configured by idf,
(Warning: python interpreter not running from IDF_PYTHON_ENV_PATH, the specific error information is as follows)

songfengchen@Songfengs-MacBook-Air ESP-IDF % . ./export.sh 
Setting IDF_PATH to '/Users/songfengchen/Documents/sean/Develop/ESP-IDF'
Detecting the Python interpreter
Checking "python" ...
Checking "python3" ...
Python 3.8.2
"python3" has been detected
Adding ESP-IDF tools to PATH...
Using Python interpreter in /usr/bin/python
Checking if Python packages are up to date...
The following Python requirements are not satisfied:
click>=7.0
pyserial>=3.3
pyparsing>=2.0.3,<2.4.0
pyelftools>=0.22
gdbgui==0.13.2.0
pygdbmi<=0.9.0.2
python-socketio<5
kconfiglib==13.7.1
reedsolo>=1.5.3,<=1.5.4
bitstring>=3.1.6
ecdsa>=0.16.0
construct==2.10.54
To install the missing packages, please run "/Users/songfengchen/Documents/sean/Develop/ESP-IDF/install.sh"
Diagnostic information:
    IDF_PYTHON_ENV_PATH: /Users/songfengchen/.espressif/python_env/idf4.4_py3.8_env
    Python interpreter used: /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
    Warning: python interpreter not running from IDF_PYTHON_ENV_PATH
    PATH: /opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:PATH=/Users/songfengchen/Documents/sean/Develop/ESP-IDF/components/esptool_py/esptool:/Users/songfengchen/Documents/sean/Develop/ESP-IDF/components/espcoredump:/Users/songfengchen/Documents/sean/Develop/ESP-IDF/components/partition_table:/Users/songfengchen/Documents/sean/Develop/ESP-IDF/components/app_update:/Users/songfengchen/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin:/Users/songfengchen/.espressif/tools/xtensa-esp32s2-elf/esp-2021r1-8.4.0/xtensa-esp32s2-elf/bin:/Users/songfengchen/.espressif/tools/xtensa-esp32s3-elf/esp-2021r1-8.4.0/xtensa-esp32s3-elf/bin:/Users/songfengchen/.espressif/tools/riscv32-esp-elf/esp-2021r1-8.4.0/riscv32-esp-elf/bin:/Users/songfengchen/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin:/Users/songfengchen/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin:/Users/songfengchen/.espressif/tools/openocd-esp32/v0.10.0-esp32-20210401/openocd-esp32/bin:/Users/songfengchen/.espressif/python_env/idf4.4_py3.8_env/bin:/Users/songfengchen/Documents/sean/Develop/ESP-IDF/tools:$PATH:export IDF_PATH=/Users/songfengchen/Documents/sean/Develop/ESP-IDF:export SDK_PATH=/Users/songfengchen/Documents/sean/Develop/ESP-IDF:export IDF_TOOLS_EXPORT_CMD=/Users/songfengchen/Documents/sean/Develop/ESP-IDF/export.sh:export IDF_TOOLS_INSTALL_CMD=/Users/songfengchen/Documents/sean/Develop/ESP-IDF/install.sh:export IDF_PYTHON_ENV_PATH=/Users/songfengchen/.espressif/python_env/idf4.4_py3.8_env:/Applications/VMware Fusion.app/Contents/Public:/Library/Apple/usr/bin
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named click
Traceback (most recent call last):
  File "/Users/songfengchen/Documents/sean/Develop/ESP-IDF/tools/idf.py", line 36, in <module>
    from idf_py_actions.tools import executable_exists, idf_version, merge_action_lists, realpath  # noqa: E402
  File "/Users/songfengchen/Documents/sean/Develop/ESP-IDF/tools/idf_py_actions/tools.py", line 8, in <module>
    import click
ImportError: No module named click
(eval):1: bad pattern: [/Users/songfengchen/Documents/sean/Develop/ESP-IDF/tools,
WARNING: Failed to load shell autocompletion for zsh version: 5.8!

   vi ~/.bash_profile
Add: alias python = "/ users / songfengchen /. Stress / python_env / idf4.4_py3.9_env / bin / python3.9"
Where songfengchen is the current mac user name
After saving and exiting, execute source ~ / bash_ Profile makes the configuration effective 6. Run/ export.sh, it must be two points with a space in the middle, and the IDF environment variable can be set correctly. The information is as follows:

songfengchen@Songfengs-MacBook-Air ESP-IDF % . ./export.sh         
Detecting the Python interpreter
Checking "python" ...
Checking "python3" ...
Python 3.9.6
"python3" has been detected
Adding ESP-IDF tools to PATH...
Using Python interpreter in python: aliased to /Users/songfengchen/.espressif/python_env/idf4.4_py3.9_env/bin/python3.9
Checking if Python packages are up to date...
Python requirements from /Users/songfengchen/Documents/sean/Develop/ESP-IDF/requirements.txt are satisfied.
Updated PATH variable:
  /Users/songfengchen/Documents/sean/Develop/ESP-IDF/components/esptool_py/esptool:/Users/songfengchen/Documents/sean/Develop/ESP-IDF/components/espcoredump:/Users/songfengchen/Documents/sean/Develop/ESP-IDF/components/partition_table:/Users/songfengchen/Documents/sean/Develop/ESP-IDF/components/app_update:/Users/songfengchen/.espressif/python_env/idf4.4_py3.9_env/bin:/opt/homebrew/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:PATH=/Users/songfengchen/Documents/sean/Develop/ESP-IDF/components/esptool_py/esptool:/Users/songfengchen/Documents/sean/Develop/ESP-IDF/components/espcoredump:/Users/songfengchen/Documents/sean/Develop/ESP-IDF/components/partition_table:/Users/songfengchen/Documents/sean/Develop/ESP-IDF/components/app_update:/Users/songfengchen/.espressif/tools/xtensa-esp32-elf/esp-2021r1-8.4.0/xtensa-esp32-elf/bin:/Users/songfengchen/.espressif/tools/xtensa-esp32s2-elf/esp-2021r1-8.4.0/xtensa-esp32s2-elf/bin:/Users/songfengchen/.espressif/tools/xtensa-esp32s3-elf/esp-2021r1-8.4.0/xtensa-esp32s3-elf/bin:/Users/songfengchen/.espressif/tools/riscv32-esp-elf/esp-2021r1-8.4.0/riscv32-esp-elf/bin:/Users/songfengchen/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin:/Users/songfengchen/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin:/Users/songfengchen/.espressif/tools/openocd-esp32/v0.10.0-esp32-20210401/openocd-esp32/bin:/Users/songfengchen/.espressif/python_env/idf4.4_py3.8_env/bin:/Users/songfengchen/Documents/sean/Develop/ESP-IDF/tools:$PATH:export IDF_PATH=/Users/songfengchen/Documents/sean/Develop/ESP-IDF:export SDK_PATH=/Users/songfengchen/Documents/sean/Develop/ESP-IDF:export IDF_TOOLS_EXPORT_CMD=/Users/songfengchen/Documents/sean/Develop/ESP-IDF/export.sh:export IDF_TOOLS_INSTALL_CMD=/Users/songfengchen/Documents/sean/Develop/ESP-IDF/install.sh:export IDF_PYTHON_ENV_PATH=/Users/songfengchen/.espressif/python_env/idf4.4_py3.8_env:/Applications/VMware Fusion.app/Contents/Public:/Library/Apple/usr/bin
Done! You can now compile ESP-IDF projects.
Go to the project directory and run:

  idf.py build

7. At this point, you can enter the project directory to compile, or make menuconfnig
8. Note that each time you open a new terminal window, you need to enter the IDF directory and execute source ~ / bash_ Profile (set python to 3.9), and then execute/ export.sh set the IDF environment variable, and then enter the project for compilation

Keywords: Python

Added by ki on Sat, 15 Jan 2022 21:46:55 +0200