2
votes

I'm trying to deploy a script on google cloud functions for the first time. I went through the documentation and figured out the basics. Then, I started trying to deploy my actual script. I'm facing an error with dependencies from the requirements.txt file. I'm at the stage where I don't know enough to be specific about my problem so I'll list down what I did.

After I run the gcloud command gcloud functions deploy FILENAME --runtime python37 with my file name, I hit this error:

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: 
{
  "error": {
    "canonicalCode": "INVALID_ARGUMENT",
    "errorMessage": "`pip_download_ wheels` had stderr output:\nERROR: Could not find 
                      a version that satisfies the requirement pywin32==227 (from -r requirements.txt (line 32)) 
                      (from versions: n one)\nERROR:\r\nNo matching distribution found for pywin32==227 (from -r requirements.txt (line 32))
                      \n\nerror: `pip_download_wheels` returned code: 1",
    "errorTyp e": "InternalError",
    "errorId": "8C994D6A"
  }
}

This is my requirements.txt file:

attrs==19.3.0
autobahn==20.4.3
Automat==20.2.0
cachetools==4.1.0
certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
constantly==15.1.0
cryptography==2.9.2
enum34==1.1.10
google-api-core==1.17.0
google-auth==1.14.1
google-cloud-bigquery==1.24.0
google-cloud-core==1.3.0
google-resumable-media==0.5.0
googleapis-common-protos==1.51.0
hyperlink==19.0.0
idna==2.9
incremental==17.5.0
kiteconnect==3.8.2
numpy==1.18.3
pandas==1.0.3
protobuf==3.11.3
pyarrow==0.17.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
PyHamcrest==2.0.2
pyOpenSSL==19.1.0
python-dateutil==2.8.1
pytz==2020.1
pywin32==227
requests==2.23.0
rsa==4.0
service-identity==18.1.0
six==1.14.0
tqdm==4.45.0
Twisted==20.3.0
txaio==20.4.1
urllib3==1.25.9
wincertstore==0.2
zope.interface==5.1.0

Can you help me figure out how to get past this error?


Edit: Based on the suggestion to only keep required dependencies in the requirements.txt file, I tried that and I'm getting a slightly different error

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed:
{
  "error": {
    "canonicalCode": "INVALID_ARGUMENT",
    "errorMessage": "`pip_download_\r\nwheels` had stderr output:
                      \n  WARNING: Legacy build of wheel for 'kiteconnect' created no files.
                      \n  Command arguments: /opt/python3.7/bin/python3.7 -u -c 'imp\r\nort sys, setuptools, tokenize; sys.argv[0] = '\"'\"'/tmp/pip-wheel-fdr9r30n/kiteconnect/setup.py'\"'\"'; __file__='\"'\"'/tmp/pip-wheel-fdr9r30n/kiteconnect/s\r\netup.py'\"'\"';f=getattr(tokenize, '\"'\"'open'\"'\"', open)(__file__);code=f.read().replace('\"'\"'\\r\\n'\"'\"', '\"'\"'\\n'\"'\"');f.close();exec(compile(c\r\node, __file__, '\"'\"'exec'\"'\"'))' bdist_wheel -d /tmp/pip-wheel-zkanpa3p\n  Command output: [use --verbose to show]\nERROR: Failed to build one or more whe\r\nels\n\nerror: `pip_download_wheels` returned code: 1",
    "errorType": "InternalError",
    "errorId": "7EF920E4"
  }
}

The new requirements.txt file looks like this:

google-api-core==1.17.0
google-auth==1.14.1
google-cloud-bigquery==1.24.0
google-cloud-core==1.3.0
google-resumable-media==0.5.0
googleapis-common-protos==1.51.0
kiteconnect==3.8.2
numpy==1.18.3
pandas==1.0.3
pyarrow==0.17.0
python-dateutil==2.8.1
tqdm==4.45.0
1

1 Answers

3
votes

The pywin32 package only provides distributions for the Windows platform, so you won't be able to install it in the Google Cloud Functions runtime.

Do you really need it? Your requirements.txt file looks like the output of pip freeze. You probably don't need all those dependencies. It should only include the dependencies you need to import in your function.