0
votes

I am experiencing a strange issue with dependencies when deploying my application to Google App Engine (Python 2.7).

I have specified my dependencies in the requirements.txt file:

Flask==1.0.2
werkzeug>=0.14
flask-cors
twilio
httplib2
gunicorn
Jinja2
google-cloud-ndb
exponent_server_sdk

These work fine with the local development server when installed locally with pip from the requirements.txt folder.

However, when I deploy to app engine, it appears that the module exponent_server_sdk has not been installed (ImportError: No module named exponent_server_sdk).

I normally deploy by pushing to a git repository which is then deployed with Google Cloud Build ("gcr.io/cloud-builders/gcloud"). There are no errors when I deploy and other dependencies in the requirements.txt file work fine such as twilio or Jinja2.

Whilst investigating this I tried pushing directly from my development machine with gcloud app deploy. When I do this, for some strange reason, exponent_server_sdk is available and works correctly.

This behaviour seems very strange to me and I can't find any documentation of people experiencing similar errors. I wonder if anyone can give me any guidance about what might be causing this issue or places I can look to find errors (for example logs of the process of installing the requirements.txt file during deployment/instance startup).

In response to the comments:

I am running in the standard environment.

My cloudbuild.yaml looks like this:

steps:
- name: "gcr.io/cloud-builders/gcloud"
  args: ["app", "deploy", "app.yaml", "dispatch.yaml", "service_1.yaml", "service_2.yaml", "service_3.yaml", "index.yaml"]
timeout: "1600s"

The .yaml file for the service in which I am experiencing the error looks like this:

runtime: python27
api_version: 1
threadsafe: true
service: notifications

libraries:
- name: ssl
  version: latest

handlers:
- url: /.*
  script: notifications.app
1
Can you show use the cloudbuild.yaml file you use to deploy?LundinCast
Standard environment?Dan Cornilescu
@DanCornilescu Yes, I am using the standard environmentuser1492867
@LundinCast I have added the cloudbuild.yamluser1492867
Can you add the app.yaml file of the service that is faulting?Juancki

1 Answers

0
votes

For the (1st gen) standard environment the deployment process does not use a requirements.txt file, the libraries should be installed inside your app. From Copying a third-party library:

Use pip (version 6 or later) with the -t <directory> flag to copy the libraries into the folder you created in the previous step. For example:

pip install -t lib/ <library_name>

Yes, if you want you can use a requirements.txt file to do the installation inside your app, but that file itself is not used by the deployment process.

Since you're not deploying directly from the environment in which you had the libraries installed you'd have to add the installation directory to the git repo as well.