Closed
Description
Environment details
I am deploying a pubsub function to python3.7 with the serverless framework using "serverless-google-cloudfunctions": "^2.3.2"
and "serverless-python-requirements": "^4.3.0"
.
I am using google-cloud-pubsub==0.45.0
in requirements.txt
Steps to reproduce
- Run
serverless deploy
and I get the error.
My Code
I am deploying a Google Cloud function that uses the pubsub API to publish a message. However, I am getting the following error:
ImportError: cannot import name 'cygrpc' from 'grpc._cython'
It seems to be because you can't pip install a C library with requirements.txt. How to I fix this? My code is below.
from google.cloud import pubsub
publisher = pubsub.PublisherClient()
path = publisher.topic_path("my_proj", "my_topic")
publisher.publish(path, "test".encode("utf-8"))
My requirements.txt is the following. I have tried adding grpcio==1.22.0 to no avail.
google-cloud-pubsub==0.45.0
My serverless.yml:
service: my-service
provider:
name: google
stage: ${opt:stage, 'dev'}
runtime: python37
region: us-central1
project: ${self:custom.env.PROJECT_NAME}
credentials: ~/.gcloud/keyfile.json
plugins:
- serverless-google-cloudfunctions
- serverless-python-requirements
custom:
pythonRequirements:
fileName: private_requirements.txt
pythonBin: python3
noDeploy:
- requirements.txt
stage:
${self:provider.stage}
env:
${file(./.env.${self:provider.stage})}
package:
include:
- requirements.txt
exclude:
- .git/**
- .gitignore
- env*
- node_modules/**
- package.json
- private_requirements.txt
- yarn.lock