title: How do I run custom python script in Google App engine
body: <p>Apologies for the long detailed question. Here goes...</p>
  
  <p>The file has the name send_daily_report.py and uses some libraries which are detailed in a requirements.txt file.</p>
  
  <p>My <strong><em>app.yaml</em></strong> looks as follows:</p>
  
  <pre><code>runtime: python27
  threadsafe: false
  
  handlers:
  - url: /send_daily_report
    script: send_daily_report.py
  
  libraries:
  - name: ssl
    version: latest
  </code></pre>
  
  <p>My <strong><em>cron.yaml</em></strong> looks as follows:</p>
  
  <pre><code>cron:
  - description: "Send unsent subscriptions to Glocell rewards every 1 minute"
    url: /send_daily_report
    schedule: every 1 day from 00:00
  </code></pre>
  
  <p>And finally my <strong><em>requirements.txt</em></strong> has the following contents:</p>
  
  <pre><code>Babel==2.5.3
  cachetools==3.1.0
  certifi==2017.11.5
  chardet==3.0.4
  coloredlogs==8.0
  colorlog==3.1.0
  et-xmlfile==1.0.1
  google-api-core==1.10.0
  google-auth==1.6.3
  google-cloud-core==0.29.1
  google-cloud-storage==1.15.0
  google-resumable-media==0.3.2
  googleapis-common-protos==1.5.10
  humanfriendly==4.6
  idna==2.6
  jdcal==1.3
  money==1.3.0
  mysql-connector-python==8.0.5
  mysqlclient==1.3.12
  numpy==1.16.3
  openpyxl==2.5.0
  pandas==0.24.2
  protobuf==3.7.1
  pyasn1==0.4.5
  pyasn1-modules==0.2.5
  python-dateutil==2.8.0
  python-magic==0.4.15
  pytz==2017.3
  requests==2.18.4
  rsa==4.0
  six==1.12.0
  urllib3==1.22
  </code></pre>
  
  <p>When I do a: </p>
  
  <blockquote>
    <p>gcloud app deploy app.yaml cron.yaml </p>
  </blockquote>
  
  <p>it seems to ignore my requirements.txt and doesn't install the dependent. I even ran it in the gcloud dev server (<a href="https://cloud.google.com/appengine/docs/standard/python/tools/using-local-server" rel="nofollow noreferrer">dev_appserver.py</a> ./app.yaml --enable_console) locally and the libraries are definitely not being installed when I use the dev server console to try and import them.</p>
  
  <p>I then tried to use Python 3.7. which actually installs the libraries in requirements.txt but the problem is in the app.yaml in the handlers I cannot specify the script name. For python 3.7 that value is always set to auto as per the <a href="https://cloud.google.com/appengine/docs/standard/python3/config/appref" rel="nofollow noreferrer">gcloud app.yaml reference</a>. </p>
  
  <p>What do I need to do to execute my script in gcloud app engine cron. On a linux system this would have been a simple cronjob setup in the crontab as follows:</p>
  
  <blockquote>
    <p>0 0 * * * python /send_daily_py</p>
  </blockquote>
  
  <p>From what i'm reading about Python 3.7, it seems like I need to have django or flex to handle the requests and route them to execute my custom .py script which seems like overkill just so that I can execute one script. Surely there is a way around this?. I even tried to include the libraries in a subfolder within my app folder as follows:</p>
  
  <blockquote>
    <p>pip install --upgrade -r requirements.txt -t ./lib</p>
  </blockquote>
  
  <p>Then I added <strong>init</strong>.py within lib, and then I changed all my imports to use </p>
  
  <blockquote>
    <p>import lib.name_of_library</p>
  </blockquote>
  
  <p>Which did not work as those libraries could subsequently not import sub packages they need.</p>
  
  <p>**</p>
  
  <h2>Heeeeelp!</h2>
  
  <p>**</p>