我正在尝试创建 Shapely 并将其导出为 AWS Lambda 层。它需要是 Python 3.6 版才能使用我的 lambda 代码
为此,我尝试了以下方法
mkdir folder
cd folder
virtualenv --python=python3.6 myvenv
source ./v-env/bin/activate
pip3 install shapely
deactivate
mkdir shapely
cd shapely
cp -r ../v-env/lib/python3.6/site-packages/* .
cd ..
zip -r shapely.zip shapely
aws lambda publish-layer-version --layer-name shapely --zip-file fileb://shapely.zip --compatible-runtimes python3.6
但是 source ./v-env/bin/activate
返回错误 bash: ./v-env/bin/activate: No such file or directory
如何为 python 3.6 激活虚拟环境?
答案 0 :(得分:0)
您称您的环境为 myvenv
而不是 v-env
,所以应该是:
source ./myvenv/bin/activate
答案 1 :(得分:0)
您正在创建一个名为 myvenv
的环境,该环境将创建文件夹 myvenv
,但随后尝试转到不存在的文件夹 v-env
。
步骤应该是:
mkdir folder
cd folder
virtualenv --python=python3.6 v-env
source ./v-env/bin/activate
pip3 install shapely
deactivate
mkdir shapely
cd shapely
cp -r ../v-env/lib/python3.6/site-packages/* .
cd ..
zip -r shapely.zip shapely
aws lambda publish-layer-version --layer-name shapely --zip-file fileb://shapely.zip --compatible-runtimes python3.6