Is it possible to use Anaconda packages as dependencies for Google Cloud Functions?

谁说胖子不能爱 提交于 2020-06-27 10:12:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!