Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'docevents' from 'botocore.docs.bcdoc' in AWS CodeBuild

ImportError: cannot import name 'docevents' from 'botocore.docs.bcdoc'
(/python3.7/site-packages/botocore/docs/bcdoc/init.py)

Traceback (most recent call last):
  File "/root/.pyenv/versions/3.7.6/bin/aws", line 19, in <module>
    import awscli.clidriver

  File "/root/.pyenv/versions/3.7.6/lib/python3.7/site-packages/awscli/clidriver.py", line 36, in <module>
    from awscli.help import ProviderHelpCommand

  File "/root/.pyenv/versions/3.7.6/lib/python3.7/site-packages/awscli/help.py", line 23, in <module>
    from botocore.docs.bcdoc import docevents

ImportError: cannot import name 'docevents' from 'botocore.docs.bcdoc' (/root/.pyenv/versions/3.7.6/lib/python3.7/site-packages/botocore/docs/bcdoc/__init__.py)

[Container] 2020/10/29 16:48:39 Command did not exit successfully aws --version exit status 1

The failure occurs in the PRE_BUILD.

And this is my spec build file: buildspec-cd.yml

pre_build:
    commands:
      - AWS_REGION=${AWS_DEFAULT_REGION}
      - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
      - IMAGE_VERSION=${COMMIT_HASH}
      - REPOSITORY_URI=${CONTAINER_REGISTRY}/${APPLICATION_NAME}
      - aws --version
      - echo Logging in to Amazon ECR...
      - $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)

The codebuild was working correctly and nothing has been changed. Only stopped working.

like image 920
Juan Rey Hernández Avatar asked Oct 29 '20 17:10

Juan Rey Hernández


2 Answers

Reading this GitHub issue #2596. i fixed my error.

Just before the PRE_BUILD section, I added this line to my buildspec-cd.yml file:

pip3 install --upgrade awscli

install:
    commands:
      - pip3 install awsebcli --upgrade
      - eb --version
      - pip3 install --upgrade awscli

    pre_build:
      commands:
      - AWS_REGION=${AWS_DEFAULT_REGION}
      - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
      - IMAGE_VERSION=${COMMIT_HASH}
      ...
like image 71
Juan Rey Hernández Avatar answered Oct 31 '22 11:10

Juan Rey Hernández


For me it's a version issue. So, I fixed it with below versions:

  1. aws-cli/1.18.105

Command: sudo python3 -m pip3 install awscli==1.18.105

  1. botocore/1.17.28

Command: sudo python3 -m pip3 install botocore==1.17.28

like image 14
vijay rajput Avatar answered Oct 31 '22 12:10

vijay rajput