问题
I am trying to deploy a Python3.7 Google Cloud Function using the "madmom" python pip package, however specifying madmom==0.16.1
in requirements.txt causes a deployment failure. When I remove madmom from requirements.txt, but leave the other pip packages, the cloud function deploys fine.
madmom pypi: https://pypi.org/project/madmom/
madmom github: https://github.com/CPJKU/madmom
I a deploying the function from Google Cloud Function's online editor: https://console.cloud.google.com/functions/add
I have deployed Python Google Cloud Functions before and this is the first time I've had issues. Any help would be very appreciated! I've been trying to find solutions online all day and haven't found anything.
Requirements.txt:
Cython==0.29.12
ffmpeg==1.4
flask==1.0.2
madmom==0.16.1
mido==1.2.9
numpy==1.16.4
scipy==1.3.0
six==1.12.0
urllib3==1.24.2
Google Cloud Function Deployment Failure:
Deployment failure:
Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "
pip_download_wheels
had stderr output:\nCommand \"python setup.py egg_info\" failed with error code 1 in /tmp/pip-wheel-qjxrm41i/madmom/\n\nerror:pip_download_wheels
returned code: 1", "errorType": "InternalError", "errorId": "66F138B2"}}
I sincerely appreciate the help!
回答1:
The issue is with the madmom
package: it has a build-time dependency on cython
and numpy
, but they aren't declared properly. Cloud Functions (like most runtimes) installs all your dependencies at the same time, but madmom
needs cython
and numpy
installed before it can be installed, which isn't configurable via a simple requirements.txt
file.
I've made a PR to fix this, it's been merged and will probably be in the next release.
In the meantime, you can install madmom
from the source repository by using the following requirements.txt
file:
git+https://github.com/CPJKU/madmom.git#egg=madmom
ffmpeg==1.4
flask==1.0.2
(note that you shouldn't specify all the sub-dependencies of your top-level dependencies here (like Cython
and urllib3
, unless you're actually importing them in your Cloud Function)
来源:https://stackoverflow.com/questions/58233081/python-google-cloud-function-deployment-failure-madmom-pip-package