Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP-IDF install.sh fails with Syntax Error (IDFGH-7302) #8890

Closed
taguniversalmachine opened this issue May 3, 2022 · 4 comments
Closed

ESP-IDF install.sh fails with Syntax Error (IDFGH-7302) #8890

taguniversalmachine opened this issue May 3, 2022 · 4 comments
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@taguniversalmachine
Copy link

Problem Description

In an effort to once and for all get IDF working in a consistent basis, I made a Docker image that installs all the prerequisites, including Python, and yet I still can't get the install script to work, I assume it's a python versioning error but nothing I do can force it to use Python3.

Expected Behavior

install.sh esp32 should install the tools

Actual Behavior

> [16/24] RUN ./install.sh esp32:
#19 0.410 Detecting the Python interpreter
#19 0.410 Checking "python" ...
#19 0.412 /esp/esp-idf/tools/detect_python.sh: line 16: python: command not found
#19 0.414 Checking "python3" ...
#19 0.454 Python 3.5.2
#19 0.454 "python3" has been detected
#19 0.455 Installing ESP-IDF tools
#19 0.476   File "/esp/esp-idf/tools/idf_tools.py", line 382
#19 0.476     msg = f'Rename {path_from} to {path_to} failed'
#19 0.476                                                   ^
#19 0.476 SyntaxError: invalid syntax
------
executor failed running [/bin/sh -c ./install.sh esp32]: exit code: 1

Steps to reproduce

Make a Dockerfile that installs python3, and checks out the 4.4 branch of ESP-IDF

FROM ubuntu
# Python
RUN apt-get install --reinstall ca-certificates
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update
RUN apt-get install -y python3
RUN alias  python=python3
RUN apt-get install -y python3-pip
RUN pip3 install --user pipenv

#ESP-IDF
RUN apt-get install -y git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
RUN mkdir -p /esp
WORKDIR "/esp"
RUN git clone -b v4.4.1 --recursive https://github.com/espressif/esp-idf.git
WORKDIR "/esp/esp-idf"
ENV  ESP_PYTHON=python3
RUN ./install.sh esp32
@espressif-bot espressif-bot added the Status: Opened Issue is new label May 3, 2022
@github-actions github-actions bot changed the title ESP-IDF install.sh fails with Syntax Error ESP-IDF install.sh fails with Syntax Error (IDFGH-7302) May 3, 2022
@dobairoland
Copy link
Collaborator

dobairoland commented May 4, 2022

Hi @taguniversalmachine. There are already official ESP-IDF docker images available (for each release branches). The source can be found here and the documentation here. You can use the source if you want to build your own version.

You can ignore this:

#19 0.412 /esp/esp-idf/tools/detect_python.sh: line 16: python: command not found

If there is no python then it will try to use python3. If you really want to make python to be python3 then please don't try to alias it. It won't work. Please use the update-alternatives as shown in the linked sources instead.

#19 0.454 Python 3.5.2
#19 0.454 "python3" has been detected
#19 0.455 Installing ESP-IDF tools
#19 0.476   File "/esp/esp-idf/tools/idf_tools.py", line 382
#19 0.476     msg = f'Rename {path_from} to {path_to} failed'

The issue here is that Python 3.5 is available and ESP-IDF v4.4 requires 3.6 or newer. You can switch to a newer version of the OS or install a suitable python in your docker. You can achieve this by adding a mirror to apt or install Python from sources.

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels May 4, 2022
@taguniversalmachine
Copy link
Author

Awesome, thanks fo r the excellent support.

@espressif-bot espressif-bot added Resolution: Done Issue is done internally Status: Done Issue is done internally and removed Status: In Progress Work is in progress labels May 4, 2022
@Alvin1Zhang
Copy link
Collaborator

Reopen until the fix is on GitHub, thanks.

@Alvin1Zhang Alvin1Zhang reopened this May 5, 2022
espressif-bot pushed a commit that referenced this issue May 11, 2022
ESP-IDF v4.4 supports Python 3.6 or newer. F-strings are available there
but idf_tools.py can fail if run with older Pythons because the Python
version check is done later.

Closes #8890
@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting, fix is available 7b33262.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

4 participants