问题
I am writing a Google Cloud Function using the Python Runtime and I need to include some dependencies which are not available with pip. As described in the docs here, it should be possible to package local dependencies, however, in my case, I would like to use all the packages of a local Anaconda environment and upload them with the function. Is there a way to do so?
Or alternatively, is there a way to specify Anaconda packages in the requirements.txt file instead of using pip?
回答1:
No, it's not possible, Cloud Functions only supports installing from PyPI via pip.
You may be interested in using Cloud Run instead, which will allow you to define your own runtime, and thus install Anaconda packages via conda.
回答2:
You can achieve this through the requirements.txt file. As each Cloud Function has its own file, you can specify different dependencies on each one.
Check this answer to a similar question:
This is an example of a bunch of dependencies in a requirements.txt
# Function dependencies, for example:
# package>=version
Flask==1.0.2
dill>=0.2.8
numpy>=1.15.0
requests>=2.20.0
six==1.12.0
spacy>=2.1.0
https://download.pytorch.org/whl/cpu/torch-1.0.1.post2-cp37-cp37m-linux_x86_64.whl
torchtext>=0.3.1
来源:https://stackoverflow.com/questions/57431462/is-it-possible-to-use-anaconda-packages-as-dependencies-for-google-cloud-functio