serverless / serverless-python-requirements

โšก๏ธ๐Ÿ๐Ÿ“ฆ Serverless plugin to bundle Python packages
MIT License
1.11k stars 290 forks source link

serverless deploy -> Exited with code 1 #663

Open StayFoolisj opened 2 years ago

StayFoolisj commented 2 years ago

Are you certain it's a bug?

Is the issue caused by a plugin?

Are you using the latest version?

Is there an existing issue for this?

Issue description

Error: docker run --rm -v /Users/bad_ape/Library/Caches/serverless-python-requirements/36d8e2271e2d9e8afb4b103da1d57dc91ab0ccc62422d1337b5a3a91dcc7c2d9_x86_64_slspyc:/var/task:z -v /Users/bad_ape/Library/Caches/serverless-python-requirements/downloadCacheslspyc:/var/useDownloadCache:z -u 0 lambci/lambda:build-python3.8 python3.8 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache Exited with code 1

Service configuration (serverless.yml) content

service: liqs

frameworkVersion: '2'

provider:
  name: aws
  runtime: python3.8
  lambdaHashingVersion: 20201221

functions:
  hello:
    handler: lambda_function.hello

plugins:
  - serverless-python-requirements

custom:
  pythonRequirements:
    dockerizePip: non-linux

Command name and used flags

serverless deploy

Command output

Serverless: Running "serverless" installed locally (in service node_modules)
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command requirements
Serverless: Load command requirements:clean
Serverless: Load command requirements:install
Serverless: Load command requirements:cleanCache
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Skipping variables resolution with old resolver (new resolver reported no more variables to resolve)
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Generated requirements from /Users/bad_ape/Downloads/liquidations_v2-8d3d697e-5a0a-4f55-9920-31ee9b80ac90/liqs_pipeline_1/requirements.txt in /Users/bad_ape/Downloads/liquidations_v2-8d3d697e-5a0a-4f55-9920-31ee9b80ac90/liqs_pipeline_1/.serverless/requirements.txt...
Serverless: Installing requirements from /Users/bad_ape/Library/Caches/serverless-python-requirements/36d8e2271e2d9e8afb4b103da1d57dc91ab0ccc62422d1337b5a3a91dcc7c2d9_x86_64_slspyc/requirements.txt ...
Serverless: Docker Image: lambci/lambda:build-python3.8
Serverless: Using download cache directory /Users/bad_ape/Library/Caches/serverless-python-requirements/downloadCacheslspyc
Serverless: Running docker run --rm -v /Users/bad_ape/Library/Caches/serverless-python-requirements/36d8e2271e2d9e8afb4b103da1d57dc91ab0ccc62422d1337b5a3a91dcc7c2d9_x86_64_slspyc\:/var/task\:z -v /Users/bad_ape/Library/Caches/serverless-python-requirements/downloadCacheslspyc\:/var/useDownloadCache\:z -u 0 lambci/lambda\:build-python3.8 python3.8 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache...
Serverless: [AWS sts 200 1.37s 0 retries] getCallerIdentity({})

 Error ---------------------------------------------------

  Error: `docker run --rm -v /Users/bad_ape/Library/Caches/serverless-python-requirements/36d8e2271e2d9e8afb4b103da1d57dc91ab0ccc62422d1337b5a3a91dcc7c2d9_x86_64_slspyc:/var/task:z -v /Users/bad_ape/Library/Caches/serverless-python-requirements/downloadCacheslspyc:/var/useDownloadCache:z -u 0 lambci/lambda:build-python3.8 python3.8 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache` Exited with code 1
      at ChildProcess.<anonymous> (/Users/bad_ape/Downloads/liquidations_v2-8d3d697e-5a0a-4f55-9920-31ee9b80ac90/liqs_pipeline_1/node_modules/child-process-ext/spawn.js:38:8)
      at ChildProcess.emit (node:events:390:28)
      at ChildProcess.emit (node:domain:475:12)
      at maybeClose (node:internal/child_process:1062:16)
      at Socket.<anonymous> (node:internal/child_process:448:11)
      at Socket.emit (node:events:390:28)
      at Socket.emit (node:domain:475:12)
      at Pipe.<anonymous> (node:net:687:12)

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              17.2.0
     Framework Version:         2.72.0 (local)
     Plugin Version:            5.5.3
     SDK Version:               4.3.0
     Components Version:        3.18.1

Environment information

Serverless: Running "serverless" installed locally (in service node_modules)
Framework Core: 2.72.0 (local)
Plugin: 5.5.3
SDK: 4.3.0
Components: 3.18.1

MacOS Monterey 12.0.1
MB Pro 2021
Chip: Apple M1 Pro
tho-actrecipe commented 2 years ago

I got the same issue, would anyone guide me how to fix it?

Environment: linux, node 16.13.2, framework 3.15.2, plugin 6.2.2, SDK 4.3.2

Error: `python3.8 -m pip install -t /home/circleci/.cache/serverless-python-requirements/40acc2eb357179bb6100e638b660c2ac27ccd91e1a3af89a05c2b7ba5d4f9d76_arm64_slspyc -r /home/circleci/.cache/serverless-python-requirements/40acc2eb357179bb6100e638b660c2ac27ccd91e1a3af89a05c2b7ba5d4f9d76_arm64_slspyc/requirements.txt --cache-dir /home/circleci/.cache/serverless-python-requirements/downloadCacheslspyc` Exited with code 1
    at ChildProcess.<anonymous> (/home/circleci/repo/node_modules/child-process-ext/spawn.js:38:8)
    at ChildProcess.emit (node:events:390:28)
    at ChildProcess.emit (node:domain:475:12)
    at maybeClose (node:internal/child_process:1064:16)
    at Socket.<anonymous> (node:internal/child_process:450:11)
    at Socket.emit (node:events:390:28)
    at Socket.emit (node:domain:475:12)
    at Pipe.<anonymous> (node:net:687:12)

Exited with code exit status 1
milkon-fishbrain commented 2 years ago

I tried Node V16, still get a the same error on my mac.

 Error ---------------------------------------------------

  Error: `docker run --rm -v /Users/patalwell/Library/Caches/serverless-python-requirements/f4b4cffcac01d03e573bc9fb87d6d9e96378ee0b2e232c53d182e16ca5364748_x86_64_slspyc:/var/task:z -v /Users/patalwell/Library/Caches/serverless-python-requirements/downloadCacheslspyc:/var/useDownloadCache:z -e AWS_CA_BUNDLE=/Users/patalwell/Certificates/ca_bundle.pem -u 0 lambci/lambda:build-python3.7 /bin/sh -c python3.7 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache && find /var/task -name \*.so -exec strip \{\} \;` Exited with code 1
      at ChildProcess.<anonymous> (/Users/patalwell/Development/cloudshield-reports-aggregator/cloudshield-reports-aggregator/node_modules/child-process-ext/spawn.js:38:8)
      at ChildProcess.emit (node:events:390:28)
      at ChildProcess.emit (node:domain:475:12)
      at maybeClose (node:internal/child_process:1064:16)
      at Socket.<anonymous> (node:internal/child_process:450:11)
      at Socket.emit (node:events:390:28)
      at Socket.emit (node:domain:475:12)
      at Pipe.<anonymous> (node:net:687:12)

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              16.13.2
     Framework Version:         2.71.0
     Plugin Version:            5.5.3
     SDK Version:               4.3.0
     Components Version:        3.18.1

Hi, I had the same problem and everything worked fine after I started the docker app on my MacBook, so docker need to be running before "serverless deploy"

jorenvh1 commented 2 years ago

I had the same issue and after running sls deploy --verbose I got this output:

ERROR: No matching distribution found for boto3==1.23.2
WARNING: You are using pip version 21.3.1; however, version 22.1 is available.
You should consider upgrading via the '/var/lang/bin/python3.9 -m pip install --upgrade pip' command.

I'm using dockerImage: mlupin/docker-lambda:python3.9-build and probably has an outdated version of pip. Using a different image with an updated pip version will probably work. Downgrading to boto3 1.23.1 is already a quickfix in this case.

morgan-young commented 2 years ago

Hey, I am still struggling with this... can installing an older version of serverless-python-requirements help? This is really frustrating

Update

It turned out I was missing this, specifically for python 3.8:

ModuleNotFoundError: No module named 'distutils.cmd'

This wasn't letting pip run so was stopping pip from doing the thing with the requirements.

So, I installed it specifically for python 3.8 - sudo apt install python3.8-distutils and then ran sls deploy with dockerizePip set to True and it still failed (don't know why, docker :shrug:), but then I set it to False so it used pip and now it works.

I'd still really appreciate a proper reason why the dockerizePip = Trrue seems to be causing issues. Thanks

steventhanna commented 2 years ago

Perhaps unrelated, but I was getting the same error message as everyone else and realized that I had a package in my requirements.txt that didn't exist in PyPi. Removing that package allowed the deployment to continue.

vteran93 commented 2 years ago

Same error as @StayFoolisj.

I am running it in an circleCI environment with Debian Buster. I constructed and pushed the image to ECR using awscli and docker.

Serverless: [AWS ssm 200 0.097s 0 retries] getParameter({ Name: '/some/develop/stripe/api_key', WithDecryption: true })
Serverless: [AWS ssm 200 0.093s 0 retries] getParameter({ Name: '/some/gj_etl_dev/password', WithDecryption: true })
Serverless: Invoke deploy
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Using Python specified in "runtime": python3.8
Serverless: Packaging Python WSGI handler...
Serverless: Generated requirements from /root/project/requirements.txt in /root/project/.serverless/requirements.txt...
Serverless: Installing requirements from /root/.cache/serverless-python-requirements/a2ea73dc49988805a15c032f014bf5554e49fa57a518148e4d4f91a35befaeb7_x86_64_slspyc/requirements.txt ...
Serverless: Docker Image: ********.dkr.ecr.*********.amazonaws.com/some-dependencies:${ENVIRONMENT}
Serverless: Using download cache directory /root/.cache/serverless-python-requirements/downloadCacheslspyc
Serverless: Running docker run --rm -v /root/.cache/serverless-python-requirements/a2ea73dc49988805a15c032f014bf5554e49fa57a518148e4d4f91a35befaeb7_x86_64_slspyc\:/var/task\:z -v /root/.cache/serverless-python-requirements/downloadCacheslspyc\:/var/useDownloadCache\:z *******.dkr.ecr.*********.amazonaws.com/some-dependencies:\$\{ENVIRONMENT\} /bin/sh -c 'chown -R 0\\:0 /var/useDownloadCache && python3.8 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache && chown -R 0\\:0 /var/task && chown -R 0\\:0 /var/useDownloadCache'...
Serverless: [AWS sts 200 0.056s 0 retries] getCallerIdentity({})

 Error ---------------------------------------------------

  Error: `docker run --rm -v /root/.cache/serverless-python-requirements/a2ea73dc49988805a15c032f014bf5554e49fa57a518148e4d4f91a35befaeb7_x86_64_slspyc:/var/task:z -v /root/.cache/serverless-python-requirements/downloadCacheslspyc:/var/useDownloadCache:z 500345361576.dkr.ecr.*********.amazonaws.com/some-dependencies:${ENVIRONMENT} /bin/sh -c chown -R 0\:0 /var/useDownloadCache && python3.8 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache && chown -R 0\:0 /var/task && chown -R 0\:0 /var/useDownloadCache` Exited with code 125
      at ChildProcess.<anonymous> (/root/project/node_modules/child-process-ext/spawn.js:38:8)
      at ChildProcess.emit (node:events:394:28)
      at ChildProcess.emit (node:domain:475:12)
      at maybeClose (node:internal/child_process:1064:16)
      at Socket.<anonymous> (node:internal/child_process:450:11)
      at Socket.emit (node:events:394:28)
      at Socket.emit (node:domain:475:12)
      at Pipe.<anonymous> (node:net:672:12)

This is my configuration:

custom:
  wsgi:
    app: some.wsgi.application
  pythonRequirements:
    dockerImage: *****.dkr.ecr.us-east-2.amazonaws.com/some-dependencies:${ENVIRONMENT}
    dockerizePip: true
    usePoetry: false

The image was successfully built this way

FROM lambci/lambda:python3.8
USER root
COPY pyproject.toml .
COPY poetry.lock .
RUN pip install poetry
RUN poetry check && poetry export -f requirements.txt -o requirements.txt --without-hashes && poetry run pip install -r requirements.txt

Our requirements.txt is

aiobotocore==2.3.2; python_version >= "3.6"
aiofiles==0.7.0; python_version >= "3.6" and python_version < "4.0"
aiohttp==3.8.1; python_version >= "3.6"
aioitertools==0.8.0; python_version >= "3.6"
aiosignal==1.2.0; python_version >= "3.6"
aniso8601==7.0.0
asgiref==3.4.1; python_version >= "3.6" and python_version < "4.0"
async-timeout==4.0.1; python_version >= "3.6"
attrs==21.2.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
authlib==0.15.5
boto3==1.21.21; python_version >= "3.6"
botocore==1.24.21; python_version >= "3.6"
cached-property==1.5.2; python_version >= "3.6"
cachetools==4.2.4; python_version >= "3.5" and python_version < "4.0"
certifi==2021.10.8; python_full_version >= "3.6.0" and python_version >= "3.0" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0")
cffi==1.15.0; python_version >= "3.6"
charset-normalizer==2.0.9; python_full_version >= "3.6.0" and python_version >= "3.6" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0")
cloudinary==1.28.1
cryptography==36.0.0; python_version >= "3.6"
deepmerge==1.0.1
defusedxml==0.7.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.5.0"
deprecated==1.2.13; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")
diff-match-patch==20200713; python_version >= "3.6"
django-admin-autocomplete-filter==0.7.1
django-admin-easy==0.6.1
django-admin-rangefilter==0.8.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")
django-computedfields==0.1.5
django-cors-headers==3.10.1; python_version >= "3.6"
django-debug-toolbar==3.2.3; python_version >= "3.6"
django-dirtyfields==1.7.0; python_version >= "3.6"
django-extensions==3.1.5; python_version >= "3.6"
django-fernet-fields==0.6
django-fsm==2.8.0
django-graphiql-debug-toolbar==0.2.0; python_version >= "3.6" and python_version < "4.0"
django-impersonate==1.7.3
django-import-export==2.7.0; python_version >= "3.6"
django-localflavor==3.1
django-memoize==2.3.1
django-model-utils==4.2.0
django-nested-inline==0.4.4
django-polymorphic==3.1.0
django-storages==1.12.3; python_version >= "3.5"
django==3.2.13; python_version >= "3.6"
djangorestframework==3.13.0; python_version >= "3.6"
et-xmlfile==1.1.0; python_version >= "3.7"
expiringdict==1.1.4
fpdf2==2.4.6
frozenlist==1.2.0; python_version >= "3.6"
graphene-django==2.15.0
graphene==2.1.9; python_version >= "3.6" and python_version < "4.0"
graphql-core==2.3.2
graphql-relay==2.0.1
idna==3.3; python_full_version >= "3.6.0" and python_version >= "3.6" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0")
isodate==0.6.1; python_version >= "3.6"
jmespath==0.10.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6"
json-log-formatter==0.4.0
launchdarkly-server-sdk==7.2.1
lxml==4.8.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
markuppy==1.14; python_version >= "3.7"
marshmallow-dataclass==8.5.3; python_version >= "3.6"
marshmallow==3.14.1; python_version >= "3.6"
multidict==5.2.0; python_version >= "3.6"
mypy-extensions==0.4.3; python_version >= "3.6"
odfpy==1.4.1; python_version >= "3.7"
openpyxl==3.0.9; python_version >= "3.7"
pdfrw==0.4
phonenumberslite==8.12.48
pillow==8.4.0; python_version >= "3.6"
platformdirs==2.5.1; python_version >= "3.7"
promise==2.3; python_version >= "3.6" and python_version < "4.0"
psycopg2-binary==2.9.3; python_version >= "3.6"
pycparser==2.21; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
pyjwt==2.3.0; python_version >= "3.6" and python_full_version >= "3.6.0"
pypdf2==1.27.5; python_version >= "2.7"
pyrfc3339==1.1
python-dateutil==2.8.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6"
python-http-client==3.3.4; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
python-slugify==6.1.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")
python-stdnum==1.17
pytz==2021.3; python_version >= "3.6" and python_full_version >= "3.6.0" and python_version < "4.0"
pyyaml==5.4.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")
requests-file==1.5.1; python_version >= "3.6"
requests-toolbelt==0.9.1; python_version >= "3.6"
requests==2.26.0; python_full_version >= "3.6.0" and python_version >= "3.0" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0") and (python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.6.0" and python_version >= "3.6")
rx==1.6.1
s3transfer==0.5.2; python_version >= "3.6"
semver==2.13.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0"
sendgrid==6.9.2; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
sentry-sdk==1.5.1
simple-salesforce==1.11.6
singledispatch==3.7.0; python_version >= "3.6" and python_version < "4.0"
six==1.16.0; python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "4.0" or python_full_version >= "3.3.0" and python_version >= "3.6" and python_version < "4.0"
sqlparse==0.4.2; python_version >= "3.6" and python_version < "4.0"
ssm-parameter-store==19.11.0
starkbank-ecdsa==2.0.3; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
stripe==2.63.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")
tablib==3.2.1; python_version >= "3.7"
tblib==1.7.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
text-unidecode==1.3; python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.6.0"
twilio==7.3.2; python_full_version >= "3.6.0"
typing-extensions==4.0.1; python_version >= "3.6"
typing-inspect==0.7.1; python_version >= "3.6"
urllib3==1.25.11; python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.6" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0")
watchtower==1.0.6; python_version >= "3.5"
werkzeug==1.0.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
wrapt==1.13.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
xlrd==2.0.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_version >= "3.7" and python_full_version >= "3.6.0"
xlwt==1.3.0; python_version >= "3.7"
yarl==1.7.2; python_version >= "3.6"
zeep==4.1.0; python_version >= "3.6"
zenpy==2.0.24
takeda commented 2 years ago

@medikoo @pgrzesik could some more debugging be added, so more information is displayed than just error code 1 (maybe contents of stderr and stdout)? It's possible that each of us here has a different kind of issue and we are just piling up on this error. Having more information would also allow regular users to possibly find solution themselves as it is possible that it might be someting going on a local machine. For example many of us know that error code 125 is likely docker deamon not running, but if an output would be shown that person would likely resolve it himself.

isimaka commented 2 years ago

I'm facing almost the same error in a Python 3.9 runtime, but with a different error code of 125 on my Mac: Error: docker run --rm -v /Users/adasgup/apps/myproject/.serverless/requirements:/var/task:z -v /Users/adasgup/Library/Caches/serverless-python-requirements/downloadCacheslspyc:/var/useDownloadCache:z -u 0 lambci/lambda:build-python3.9 python3.9 -m pip install --no-cache-dir --find-links reqs/wheels -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache Exited with code 125

I believe this is the error you get when Docker is not running?

Serverless Framework, Python, Docker, AWS Lambda, Exited with code 125

@agneeshdg @StayFoolisj

I fixed the same problem.

No, in my case, Docker is running well.

Problem locates in the docker image: lambci/lambda:build-python3.9

On this image's docker hub, no such a tag. So Docker failed to pull the tag to local.

As @tb102122 mentioned under this issue, mlupin/docker-lambda:python3.9-build is suggested.

This worked for me.

f00f commented 2 years ago

@reznok (maybe a bit late): your issue looks like the encoding issue, see https://github.com/serverless/serverless-python-requirements/issues/442#issuecomment-831615784 (as @stevetran-96 also mentioned, but with a broken link)

AwolDes commented 2 years ago

Just adding my experience - this was fixed after using sls package --verbose finding that there's no 'lambci/lambda:build-python3.9' image, similar to what @isimaka has posted.

https://github.com/lambci/lambci/issues/138

I have added dockerImage: public.ecr.aws/sam/build-python3.9:latest to my config

pythonRequirements:
    dockerizePip: non-linux
    dockerImage: public.ecr.aws/sam/build-python3.9:latest
    slim: true
    layer: true

Now it is packaging without a problem

max-addison commented 1 year ago

Much like @AwolDes said, the issue is with 'lambci/lambda:build-python3.9'. My 'fix' was just downgrading the python version by changing my serverless.yml file to:

provider:
  name: aws
  runtime: python3.8
  ...
pgrzesik commented 1 year ago

Hey everyone in thread, I believe most of the issues reported here are caused by two things:

  1. Not great reporting of certain errors
  2. Lack of support for python3.9 when using Docker

Please look into PRs: #723 and #724 as they should improve the situation greatly.

ghost commented 1 year ago

Yes, @pgrzesik, I changed the runtime from python 3.9 to python 3.8 and it deployed without problems. Do you know where can I find more templates and examples of build aws infrastructure using aws serverless or a course, thanks.

pgrzesik commented 1 year ago

Hey @HeyVictorDanilo ๐Ÿ‘‹ Glad to hear you've been able to resolve that issue. You can look for some examples here: https://github.com/serverless/examples

RoniFinTech2 commented 1 year ago

Facing the same issue when using Python3.9 on Github Actions during CI.

Run serverless/github-action@v3.1
  with:
    args: -c "cd ./serverless && serverless package --stage dev --verbose"
    entrypoint: /bin/sh
  env:
    NODE_VERSION: 16.x
    pythonLocation: /opt/hostedtoolcache/Python/3.9.14/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.14/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.14/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.14/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.14/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.14/x64/lib
    AWS_DEFAULT_REGION: ***
    AWS_REGION: ***
    AWS_ACCESS_KEY_ID: ***
    AWS_SECRET_ACCESS_KEY: ***
    AWS_SESSION_TOKEN: ***
```
Packaging app-sls for stage dev (***)

Generated requirements from /github/workspace/serverless/requirements.txt in /github/workspace/serverless/.serverless/requirements.txt Installing requirements from "/github/workspace/serverless/.serverless/requirements/requirements.txt" Environment: linux, node 16.17.1, framework 3.23.0 (local) 3.23.0v (global), plugin 6.2.2, SDK 4.3.2 Error: Error: python3.9 -m pip help install Exited with code 1 Docs: docs.serverless.com Support: forum.serverless.com Bugs: github.com/serverless/serverless/issues

at ChildProcess.<anonymous> (/github/workspace/serverless/node_modules/child-process-ext/spawn.js:38:8)
at ChildProcess.emit (node:events:513:28)
at ChildProcess.emit (node:domain:489:12)
at maybeClose (node:internal/child_process:1093:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

1 deprecation found: run 'serverless doctor' for more details

ilyatovbin-pp commented 1 year ago

The python-requirements module throws this error without actually showing any pip errors. in my case I tried running the actual pip install command manually and saw that PIP returns an error for an incorrect package version. as soon as I fixed it, the error went away.

if anything, it should capture any error messages and throw them instead of "exited with code 1"

for docker, I guess you need to run "docker logs -f xxx" and see the actual pip output as well, look for errors and display them instead of just a 1 exit code.

pgrzesik commented 1 year ago

Thanks for reporting more @ilyatovbin-pp ๐Ÿ™‡ Were you using the latest version of the plugin? Could you provide a simple way to reproduce that problem so I can diagnose it better? Thanks in advance ๐Ÿ™‡

ilyatovbin-pp commented 1 year ago

I was on v5.4.0.
just for kicks installed npm 18.12.1 (LTS), updated serverless to latest version and tried again with same results.

you can just put any non existing package name or version in requirements.txt to get this error. for example requests==2.999 or somebadpackage==1.0.0

Error: `python3.8 -m pip install -t /home/ilya/.cache/serverless-python-requirements/4b42096495056b1a0bf6b773b4a651e3d2a33be6adbfcf82957d3e2b10db8563_x86_64_slspyc -r /home/ilya/.cache/serverless-python-requirements/4b42096495056b1a0bf6b773b4a651e3d2a33be6adbfcf82957d3e2b10db8563_x86_64_slspyc/requirements.txt --cache-dir /home/ilya/.cache/serverless-python-requirements/downloadCacheslspyc` Exited with code 1
    at ChildProcess.<anonymous> (/home/ilya/node_modules/child-process-ext/spawn.js:38:8)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1091:16)
    at Socket.<anonymous> (node:internal/child_process:449:11)
    at Socket.emit (node:events:513:28)
    at Socket.emit (node:domain:489:12)
    at Pipe.<anonymous> (node:net:313:12)

then if you manually run the pip command from above you'll get the actual error:

ERROR: Could not find a version that satisfies the requirement somebadpackage==1.0.0 (from versions: none)  
ERROR: No matching distribution found for somebadpackage==1.0.0  

I'm sure that if you display the pip error you'd solve a lot of headache for people

beatasophos commented 1 year ago

Facing the same issue when using Python3.9 on Github Actions during CI.

Run serverless/github-action@v3.1
  with:
    args: -c "cd ./serverless && serverless package --stage dev --verbose"
    entrypoint: /bin/sh
  env:
    NODE_VERSION: 16.x
    pythonLocation: /opt/hostedtoolcache/Python/3.9.14/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.14/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.14/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.14/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.14/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.14/x64/lib
    AWS_DEFAULT_REGION: ***
    AWS_REGION: ***
    AWS_ACCESS_KEY_ID: ***
    AWS_SECRET_ACCESS_KEY: ***
    AWS_SESSION_TOKEN: ***
```
Packaging app-sls for stage dev (***)

Generated requirements from /github/workspace/serverless/requirements.txt in /github/workspace/serverless/.serverless/requirements.txt Installing requirements from "/github/workspace/serverless/.serverless/requirements/requirements.txt" Environment: linux, node 16.17.1, framework 3.23.0 (local) 3.23.0v (global), plugin 6.2.2, SDK 4.3.2 Error: Error: python3.9 -m pip help install Exited with code 1 Docs: docs.serverless.com Support: forum.serverless.com Bugs: github.com/serverless/serverless/issues

at ChildProcess.<anonymous> (/github/workspace/serverless/node_modules/child-process-ext/spawn.js:38:8)
at ChildProcess.emit (node:events:513:28)
at ChildProcess.emit (node:domain:489:12)
at maybeClose (node:internal/child_process:1093:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

1 deprecation found: run 'serverless doctor' for more details

`Generated requirements from /github/workspace/requirements.txt in /github/workspace/.serverless/requirements.txt Installing requirements from "/github/home/.cache/serverless-python-requirements/58bef6d0060b6f1d11bcc14129fb3f0aa15f3839e580cfa4895a7d3411c56b26_x86_64_slspyc/requirements.txt" Using download cache directory /github/home/.cache/serverless-python-requirements/downloadCacheslspyc

Environment: linux, node 16.19.1, framework 3.28.1 (local) 3.29.0v (global), plugin 6.2.3, SDK 4.3.2 Error: python3.9 -m pip help install Exited with code 1`

Experienced exactly the same problem, so far did not found solution...

jarrod-cummings commented 1 year ago

I've also been running into the same failure as above while trying to use serverless deploy inside of a docker container

Generated requirements from /var/www/src/serverless/requirements.txt in /var/www/src/serverless/.serverless/requirements.txt
Installing requirements from "/usr/local/.cache/serverless-python-requirements/44c71bffb51a563eb8850945081619f63a4ec735828b7e8150a7400b5fda5f1f_x86_64_slspyc/requirements.txt"
Using download cache directory /usr/local/.cache/serverless-python-requirements/downloadCacheslspyc

...
ร— Stack xxx failed to deploy (0s)

Environment: linux, node 18.15.0, framework 3.29.0 (local) 3.29.0v (global), plugin 6.2.3, SDK 4.3.2

Error: `/usr/bin/python3.9 -m pip help install` Exited with code 1
    at ChildProcess.<anonymous> (/usr/local/node_modules/child-process-ext/spawn.js:38:8)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1091:16)
    at ChildProcess._handle.onexit (node:internal/child_process:302:5)
faif commented 1 year ago

Same error here, tested both with Python 3.9 and 3.8, x64 and arm64 (all combinations). I'm always getting:

Environment: linux, node 16.20.1, framework 3.33.0 (local), plugin 6.2.3, SDK 4.3.2
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues
Error:
Running "docker run --rm -v /root/.cache/serverless-python-requirements/a90009f9ea4c0b5b2cc0c3440e65fd9acd7381a42bfdf3dac3442b54d819fcf3_arm64_slspyc:/var/task:z -v /root/.cache/serverless-python-requirements/downloadCacheslspyc:/var/useDownloadCache:z public.ecr.aws/sam/build-python3.9:latest-arm64 /bin/sh -c chown -R 0\:0 /var/useDownloadCache && python3.9 -m pip install -t /var/task/ -r /var/task/requirements.txt --cache-dir /var/useDownloadCache && chown -R 0\:0 /var/task && chown -R 0\:0 /var/useDownloadCache" failed with: ""
1 deprecation found: run 'serverless doctor' for more details

Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1

Please follow the advice of @ilyatovbin-pp and add some logging because it's not clear what the problem is. My requirements.txt file is fine, I can deploy the lambda locally to AWS without problems, but it fails when ran on GitLab. Using version 6.0.0, as found in the changelog.

edwardleoni commented 1 year ago

I'm having the same issue on github actions

Python 3.10 - Node 20 happens whether I do it all manually or use serverless/github-action@v3.2

image
scottadean commented 8 months ago

I'm kind of embarrassed, but my problem was docker was not running on my mac when running sls deploy my error dump looked like this:

`Environment: darwin, node 18.15.0, framework 3.38.0 (local) 3.30.0v (global), plugin 7.2.0, SDK 4.5.1 Credentials: Local, "dev-default" profile Docs: docs.serverless.com Support: forum.serverless.com Bugs: github.com/serverless/serverless/issues

Error: Error: docker run --rm -v /Users/scott/Library/Caches/serverless-python-requirements/xxxxxx_x86_64_slspyc:/test alpine stat -c %u /bin/sh Exited with code 125`

jzhao62 commented 8 months ago

i encoutnered the same problem, the problem is gone with i remove the following packages from requirements.txt, seems like sometimes it is caused by package, nota problem from sls , any clue on this ? certifi==2023.11.17 openssl==3.0.12 cryptography==41.0.7 idna==3.4