我一直在关注Youtube视频,将python库上传到AWS Lambda。 youtuber创建了这个MakeFile,它创建了一个名为“package”的文件夹,其中包含一个“tmp”文件夹和(PROJECT).zip:
install: virtual
build: clean_package copy_python build_package_tmp remove_unused zip
virtual:
@echo "--> Setup and activate virtualenv"
if test ! -d "$(VIRTUAL_ENV)"; then pip install virtualenv;
virtualenv $(VIRTUAL_ENV); fi
@echo ""
clean_package:
rm -rf ./package/*
build_package_tmp:
mkdir -p ./package/tmp/lib
cp -R ./$(PROJECT)/. ./package/tmp/
copy_python:
if test -d $(VIRTUAL_ENV)lib; then \
cp -a $(VIRTUAL)/lib/python2.7/site-packages/. ./package/tmp/;
fi
if test -d $(VIRTUAL_ENV)/lib64; then \
cp -a $(VIRTUAL)/lib/python2.7/site-packages/. ./package/tmp/
fi
remove_unused:
rm -rf ./package/tmp/wheel*
rm -rf ./package/tmp/easy-install*
rm -rf ./package/tmp/setup-tools*
zip:
cd ./package/tmp && zip -r ../$(PROJECT).zip .
我在Linux控制台上遇到了这个错误:
$make -f Maketest.mk build
rm -rf ./package/*
if test -d envlib; then \
cp -a /lib/python2.7/site-packages/. ./package/tmp/; thenif test -d env/lib64/python2.7/site-packages/. ./package/tmp/; fi
mkdir -p ./package/tmp/lib
cp -R ./AWS/. ./package/tmp/
cp: cannot stat './AWS/.': No such file or directory
Maketest.mk:21: recipe for target 'build_package_tmp' failed
make: *** [build_package_tmp] Error 1
创建“包”,只有一个空的“tmp”。
PS:我是AWS Lambda的新手,所以如果有更好的方法可以使用Linux控制台上传,我将非常感激:)
答案 0 :(得分:0)
AWS有一个关于如何将python依赖库文件上传到lambda的更清晰的文档,
希望它有所帮助。