我正在弄清楚如何在Google Cloud Platform上部署我的脚本.
我已经创建了一个包含script.py和/ lib文件夹中所有库的目录或文件夹.
我没有得到的是设置我的app.yaml以运行script.py(python 2.7)并在需要时访问lib.
我也不知道自从我使用第三方库以来我是否需要做requirments.txt.
这是我在script.py中的所有导入
import requests
import re
import mysql.connector
from urlparse import urlparse
from urlparse import urljoin
from bs4 import BeautifulSoup
此外,我在我的库中有BeautifulSoup,requests和mysql.connector.
我不知道其他人,我认为它们是python2.7内置的,因为我无法使用pip安装它们.
即时通讯使用Windows 10的方式.
的app.yaml
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /lib/requests
script: Scrape.app
handlers:
- url: /requests
script: Scrape.app
handlers:
- url: /mysql/connector
script: Scrape.app
handlers:
- url: /bs4/
script: Scrape.app
cron.yaml
cron:
- description: "Scrape"
url: /
schedule: every 10 mins
retry_parameters:
min_backoff_seconds: 2.5
max_doublings: 10
我收到类似的错误
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
/bin/sh: 1: Python: not found
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/base/data/home/apps/s~tribal-bonito-157700/20170302t182530.399552845921654287/Scrape.py", line 3, in
import requests
ImportError: No module named requests