SAM命令失败:ImportError:无法导入名称AliasedEventEmitter
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SAM命令失败:ImportError:无法导入名称AliasedEventEmitter相关的知识,希望对你有一定的参考价值。
我正在使用buildspec.yml
文件通过AWS CodeBuild运行SAM模板我相信这个问题是由pip安装aws-sam-cli
软件包的默认python 2.7版本引起的。我不熟悉如何pip install
python3
版本的包。这是我的buildspec.yml
的片段:
phases:
pre_build:
commands:
- echo "Pre-Build Phase started - SAM Deployment"
- alias python=python3
- pip install --upgrade pip
- pip install aws-sam-cli # install the sam cli
- USER_BASE_PATH=$(python -m site --user-base) # save the path to the user's local packages folder to a variable (as opposed to the global packages folder)
- export PATH=$PATH:$USER_BASE_PATH/bin # add the user's local packages folder to PATH
- sam --version # verify "sam" can now be called
build:
commands:
- sam package --runtime python3 --template-file ${INPUT_FILE} --output-template-file ${OUTPUT_FILE} --s3-bucket ${S3_BUCKET} # package the template to an S3 bucket
...
有没有人遇到过这个问题?
答案
对于任何重新审视这个问题的人,我都明白了。以下是我修订的buildspec.yml
片段。我不得不用pip3安装awscli包。
phases:
pre_build:
commands:
- echo "Pre-Build Phase started - SAM Deployment"
- ls -ltr # list directory contents from oldest to new
- sudo apt-get update
- sudo apt-get -y install python3-pip
- sudo pip3 install --upgrade awscli
- apt-get update > /dev/null # get list of package updates from
repositories
- apt-get install jq -y > /dev/null # install 32-bit JSON processor
- jq --version # check JSON processor installed / which version
- wget -q https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 # get 64-bit JSON processor
- chmod +x jq-linux64 # make executable
- mv jq-linux64 $(which jq) # make "jq" alias point to 64-bit jq
- jq --version # verify jq points to new version
- alias python=python3
- pip install aws-sam-cli # install the sam cli
- USER_BASE_PATH=$(python -m site --user-base) # save the path to the user's local packages folder to a variable (as opposed to the global packages folder)
- export PATH=$PATH:$USER_BASE_PATH/bin # add the user's local packages folder to PATH
- sam --version # verify "sam" can now be called
build:
commands:
- sam package --template-file ${INPUT_FILE} --output-template-file ${OUTPUT_FILE} --s3-bucket ${S3_BUCKET} # package the template to an S3 bucket
以上是关于SAM命令失败:ImportError:无法导入名称AliasedEventEmitter的主要内容,如果未能解决你的问题,请参考以下文章
由于 ImportError,Celery Django 部署因 Elastic Beanstalk 失败:无法导入名称“Celery”(ElasticBeanstalk::ExternalInvoc
ffpyplayer ImportError:导入播放器时DLL加载失败
ImportError:无法导入名称“AFAVSignature”
ImportError:无法导入名称 preprocessor_pb2