gcloud preview app deploy returns 400 error - google-app-engine

Trying to deploy some static content to GAE, since they removed the push-to-deploy pipeline feature. I've setup a brand new project. It's in the US region. Did gcloud auth login again. Still getting the same response.
Verbose debug output below. [REDACTED] is my addition to the code.
$ gcloud preview app deploy dist/app.yaml --verbosity debug
DEBUG: Running gcloud.preview.app.deploy with Namespace(__calliope_internal_deepest_parser=ArgumentParser(prog='gcloud.preview.app.deploy', usage=None, description="*(BETA)* This command is used to deploy both code and configuration to the App Engine\nserver. As an input it takes one or more ``DEPLOYABLES'' that should be\nuploaded. A ``DEPLOYABLE'' can be a module's .yaml file or a configuration's\n.yaml file.", version=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False), cmd_func=<bound method Command.Run of <googlecloudsdk.calliope.backend.Command object at 0x10bf14290>>, command_path=['gcloud', 'preview', 'app', 'deploy'], deployables=['dist/app.yaml'], document=None, env_vars=None, force=False, format=None, h=None, help=None, http_timeout=None, log_http=None, markdown=None, project=None, quiet=None, remote=False, server=None, set_default=False, trace_token=None, user_output_enabled=None, verbosity='debug', version=None).
You are about to deploy the following modules:
- [PROJECT_ID]/default/20150612t130942 From: [/Users/[ME]/Dropbox/Sites/[PROJECT_ID]/site/dist/app.yaml]
Do you want to continue (Y/n)? Y
Updating module [default]...DEBUG: Host: appengine.google.com
DEBUG: Host: appengine.google.com
DEBUG: Getting current resource limits.
DEBUG: Send: /api/appversion/getresourcelimits, params={'version': '20150612t130942', 'app_id': '[PROJECT_ID]'}
DEBUG: _Authenticate configuring auth; needs_auth=False
DEBUG: Sending request to https://appengine.google.com/api/appversion/getresourcelimits?app_id=[PROJECT_ID]&version=20150612t130942 headers={'X-appcfg-api-version': '1', 'content-length': '0', 'Content-Type': 'application/octet-stream'} body=
INFO: Attempting refresh to obtain initial access_token
INFO: Refreshing access_token
DEBUG: Got response: max_file_size: 32000000
max_blob_size: 32000000
max_files_to_clone: 2000
max_total_file_size: 9223372036854775807
max_file_count: 10000
DEBUG: Using resource limits: {'max_file_size': 32000000, 'max_total_file_size': 9223372036854775807, 'max_blob_size': 32000000, 'max_files_to_clone': 2000, 'max_file_count': 10000}
INFO: Reading app configuration.
DEBUG:
Starting update of app: [PROJECT_ID], version: 20150612t130942
DEBUG: Scanning files on local disk.
INFO: Processing file [app.yaml]
INFO: Processing file [index.html]
INFO: Processing file [views/6a0e56b1.main.html]
INFO: Processing file [views/partials/90bc29e6.case-study.html]
INFO: Processing file [views/partials/cc69dea5.home.html]
INFO: Processing file [styles/9960b040.main.css]
INFO: Processing file [scripts/8a12aff1.scripts.js]
INFO: Processing file [scripts/8e6de882.libraries.js]
DEBUG: Send: /api/appversion/create, params={'version': '20150612t130942', 'app_id': '[PROJECT_ID]', 'module': 'default'}
DEBUG: _Authenticate configuring auth; needs_auth=False
DEBUG: Sending request to https://appengine.google.com/api/appversion/create?app_id=[PROJECT_ID]&module=default&version=20150612t130942 headers={'X-appcfg-api-version': '1', 'content-length': '633', 'Content-Type': 'application/octet-stream'} body=api_version: '1'
application: [PROJECT_ID]
auto_id_policy: default
builtins:
- default: 'on'
derived_file_type:
- python_precompiled
handlers:
- script: index.html
secure: optional
url: /
- secure: optional
static_dir: styles
url: /styles
- secure: optional
static_dir: scripts
url: /scripts
- secure: optional
static_dir: views
url: /views
- secure: optional
static_dir: fonts
url: /fonts
- secure: optional
static_dir: images
url: /images
- secure: optional
static_dir: res
url: /res
module: default
runtime: php
threadsafe: true
version: 20150612t130942
vm_settings:
module_yaml_path: app.yaml
INFO: Attempting refresh to obtain initial access_token
INFO: Refreshing access_token
Updating module [default].../DEBUG: Got http error 400.
DEBUG: Unexpected results: {'status': '400', 'alternate-protocol': '443:quic,p=1', 'content-length': '318', 'expires': 'Fri, 01 Jan 1990 00:00:00 GMT', 'server': 'Google Frontend', 'cache-control': 'no-cache', 'date': 'Fri, 12 Jun 2015 18:09:47 GMT', 'content-type': 'text/plain'}
Updating module [default]...done.
DEBUG: (gcloud.preview.app.deploy) Server responded with code [400]:
Bad Request Unexpected HTTP status 400
Traceback (most recent call last):
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 538, in Execute
result = args.cmd_func(cli=self, args=args)
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/calliope/backend.py", line 1124, in Run
result = command_instance.Run(args)
File "/Users/[ME]/Applications/google-cloud-sdk/lib/googlecloudsdk/appengine/app_commands/deploy.py", line 119, in Run
client.DeployModule(module, version, info.parsed, info.file)
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/appengine_client.py", line 276, in DeployModule
return appversion.DoUpload()
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/appengine_deployments.py", line 1016, in DoUpload
missing_files = self.Begin()
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/appengine_deployments.py", line 561, in Begin
payload=config_copy.ToYAML())
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/util.py", line 288, in Send
result = self.rpcserver.Send(url, payload=payload, **kwargs)
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/util.py", line 353, in Send
response = self._server.Send(*args, **kwargs)
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/external/tools/appengine_rpc_httplib2.py", line 269, in Send
'Unexpected HTTP status %s' % status)
File "/Users/[ME]/Applications/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/external/tools/appengine_rpc_httplib2.py", line 67, in RaiseHttpError
raise urllib2.HTTPError(url, response_info.status, msg, response_info, stream)
RPCError: Server responded with code [400]:
Bad Request Unexpected HTTP status 400
ERROR: (gcloud.preview.app.deploy) Server responded with code [400]:
Bad Request Unexpected HTTP status 400

You might have to set the project id again if you have disabled/removed previous application from google cloud console.
gcloud config set project PROJECT_ID

The generic issue is that the error did not have a message.
Starting in the cloud SDK release tomorrow, the reason for whatever error (billing issue, not enough quota, whatever) will be displayed, so please try to get the newer cloud SDK tomorrow.

For me I hadn't enabled billing in Compute > Compute Engine > VM instances on my Google Console project. It works now!

If you have appcfg.py installed, you can run that to deploy and it will give the exact error message, I found mine to be an invalid api_version for the java runtime (to which i can't find the valid number and 1 isn't it)

My initial deployment was fine and after I uploaded the update, it started to fail and get the same errors as you did. I found the issue with oauth. Logout from google and running:
$ gcloud auth login
After relogin, I was able to deploy. No re-coding or Managed VM setting changes were done.

Related

Google App Engine Flexible deploy throwing ERROR: (gcloud.app.deploy) HttpError accessing

Hi I am getting this error when deploying nodejs application to flexible engine. I am unable to figure out where the issue is happening.
The error message I am getting
ERROR: (gcloud.app.deploy) HttpError accessing <https://appengine.googleapis.com/v1/apps/project-id/services/testws/versions?alt=json>: response: <{'vary': 'Origin, X-Origin, Referer', 'content-type': 'application/json; charset=UTF-8', 'date': 'Fri, 26 Mar 2021 20:37:27 GMT', 'server': 'ESF', 'cache-control': 'private', 'x-xss-protection': '0', 'x-frame-options': 'SAMEORIGIN', 'x-content-type-options': 'nosniff', 'alt-svc': 'h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"', 'transfer-encoding': 'chunked', 'status': '500', 'content-length': '109', '-content-encoding': 'gzip'}>, content <{
"error": {
"code": 500,
"message": "Internal error encountered.",
"status": "INTERNAL"
}
}
>
This may be due to network connectivity issues. Please check your network settings, and the status of the service you are trying to reach.
app.yaml
runtime: nodejs
env: flex
service: testws
manual_scaling:
instances: 1
network:
session_affinity: true
resources:
cpu: 1
memory_gb: 1
disk_size_gb: 2
env_variables:
KEY: "dev"
PRIVATE_KEY_URL: "key"
skip_files:
- ^node_modules/.*$
Gcloud SDK version
Google Cloud SDK 333.0.0
bq 2.0.65
core 2021.03.19
gsutil 4.60
kubectl 1.17.17
I have added the debug logs by running gcloud app deploy --verbosity="debug"
debug logs
>
This may be due to network connectivity issues. Please check your network settings, and the status of the service you are trying to reach.
Traceback (most recent call last):
File "/Users/shashi/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 982, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/Users/shashi/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 809, in Run
resources = command_instance.Run(args)
File "/Users/shashi/google-cloud-sdk/lib/surface/app/deploy.py", line 130, in Run
use_legacy_apis=args.use_legacy_apis)
File "/Users/shashi/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 678, in RunDeploy
ignore_file=args.ignore_file)
File "/Users/shashi/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 455, in Deploy
extra_config_settings)
File "/Users/shashi/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/appengine_api_client.py", line 172, in DeployService
extra_config_settings)
File "/Users/shashi/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/appengine_api_client.py", line 249, in _CreateVersion
return self.client.apps_services_versions.Create(create_request)
File "/Users/shashi/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/appengine/v1/appengine_v1_client.py", line 830, in Create
config, request, global_params=global_params)
File "/Users/shashi/google-cloud-sdk/lib/third_party/apitools/base/py/base_api.py", line 729, in _RunMethod
http, http_request, **opts)
File "/Users/shashi/google-cloud-sdk/lib/third_party/apitools/base/py/http_wrapper.py", line 350, in MakeRequest
check_response_func=check_response_func)
File "/Users/shashi/google-cloud-sdk/lib/third_party/apitools/base/py/http_wrapper.py", line 406, in _MakeRequestNoRetry
check_response_func(response)
File "/Users/shashi/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/apis.py", line 267, in _CheckResponseForApiEnablement
http_wrapper.CheckResponse(response)
File "/Users/shashi/google-cloud-sdk/lib/third_party/apitools/base/py/http_wrapper.py", line 223, in CheckResponse
raise exceptions.BadStatusCodeError.FromResponse(response)
apitools.base.py.exceptions.BadStatusCodeError: HttpError accessing <https://appengine.googleapis.com/v1/apps/project-id/services/awsockets/versions?alt=json>: response: <{'vary': 'Origin, X-Origin, Referer', 'content-type': 'application/json; charset=UTF-8', 'date': 'Sun, 28 Mar 2021 22:29:25 GMT', 'server': 'ESF', 'cache-control': 'private', 'x-xss-protection': '0', 'x-frame-options': 'SAMEORIGIN', 'x-content-type-options': 'nosniff', 'alt-svc': 'h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"', 'transfer-encoding': 'chunked', 'status': '500', 'content-length': '109', '-content-encoding': 'gzip'}>, content <{
"error": {
"code": 500,
"message": "Internal error encountered.",
"status": "INTERNAL"
}
}
>
I found the reason for the error and the solution to fix it if anyone is facing this issue.
Reason - The App engine Flexible Service Account was accidentally deleted from the google cloud project. As mentioned in this link - service-account
The App Engine flexible environment service agent has the App Engine Flexible Environment Service Agent role. The role includes a set of permissions needed by Node.js flexible environment to manage your flexible environment apps. For example, this role includes permissions to perform the following tasks:
1. Deploying a new version.
2. Stopping or deleting existing versions.
3. Automatic weekly restarts and system updates.
Solution - Add a service account by going to IAM and adding an account of name mentioned below with role App Engine Flexible Environment Service Agent. As mentioned in this link - restore-service-account
service-[YOUR_PROJECT_NUMBER]#gae-api-prod.google.com.iam.gserviceaccount.com
I have raised an issue with google tracker to change the error message. You can track the issue here - issue-tracker
Update - adding the below image for further clarity. if you try to add the deleted account, it will be suggested by the system.
I had a similar error message when deploying to the standard environment.
To resolve it, I added the verbosity=debug flag as in gcloud app deploy --verbosity="debug" as suggested.
Then I could see my earlier token replacement step was not working, leading to an invalid app.yaml
The verbose output shows the app.yaml like this.
2022-05-25T23:39:43.8269116Z DEBUG: Converted YAML to JSON: "{
2022-05-25T23:39:43.8269423Z "basicScaling": {
2022-05-25T23:39:43.8269664Z "idleTimeout": "900s",
2022-05-25T23:39:43.8269912Z "maxInstances": 4
2022-05-25T23:39:43.8270102Z },
2022-05-25T23:39:43.8270288Z "entrypoint": {
2022-05-25T23:39:43.8270550Z "shell": "npm run start:prod"
2022-05-25T23:39:43.8270764Z },
2022-05-25T23:39:43.8271862Z "instanceClass": "B4",
2022-05-25T23:39:43.8272089Z "runtime": "nodejs16",
2022-05-25T23:39:43.8272316Z "vpcAccessConnector": {
2022-05-25T23:39:43.8272882Z "name": "projects/#{project_id}#/locations/#{region}#/connectors/sql-access-conn-#{environment}#"
2022-05-25T23:39:43.8273192Z }
2022-05-25T23:39:43.8273380Z }"
Putting in a valid project_id for the vpcAccessConnector fixed the error.

Google Cloud appengine deployment: No app found

I have inherited a php codebase that uses google appengine, so I have a fully built app locally that I am trying to deploy. But when I run:
gcloud app deploy --project project-name --verbosity=debug
I get the error below. I don't understand the staging command error because in the app.yaml I specify runtime: php55. I don't know what the API endpoint error means, and I also don't understand why no app was found. Any help on any of these errors would be much appreciated.
DEBUG: Running [gcloud.app.deploy] with arguments: [--project:
"project-name", --verbosity: "debug"] DEBUG: No staging command found
for runtime [php55] and environment [STANDARD]. DEBUG: API endpoint:
[https://appengine.googleapis.com/], API version: [v1] DEBUG: No app
found: Traceback (most recent call last): File
"/Users/myname/Downloads/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py",
line 679, in _PossiblyCreateApp
return api_client.GetApplication() File "/Users/myname/Downloads/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/appengine_api_client.py",
line 66, in GetApplication
return self.client.apps.Get(request) File "/Users/myname/Downloads/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/appengine/v1/appengine_v1_client.py",
line 1124, in Get
config, request, global_params=global_params) File "/Users/myname/Downloads/google-cloud-sdk/lib/third_party/apitools/base/py/base_api.py",
line 722, in _RunMethod
return self.ProcessHttpResponse(method_config, http_response, request) File
"/Users/myname/Downloads/google-cloud-sdk/lib/third_party/apitools/base/py/base_api.py",
line 728, in ProcessHttpResponse
self.__ProcessHttpResponse(method_config, http_response, request)) File
"/Users/myname/Downloads/google-cloud-sdk/lib/third_party/apitools/base/py/base_api.py",
line 599, in __ProcessHttpResponse
http_response, method_config=method_config, request=request) HttpNotFoundError: HttpError accessing
https://appengine.googleapis.com/v1/apps/project-name?alt=json:
response: <{'status': '404', 'content-length': '136',
'x-xss-protection': '0', 'x-content-type-options': 'nosniff',
'transfer-encoding': 'chunked', 'vary': 'Origin, X-Origin, Referer',
'server': 'ESF', '-content-encoding': 'gzip', 'cache-control':
'private', 'date': 'Tue, 24 Sep 2019 22:49:44 GMT', 'x-frame-options':
'SAMEORIGIN', 'alt-svc': 'quic=":443"; ma=2592000; v="46,43"',
'content-type': 'application/json; charset=UTF-8'}>, content <{
"error": {
"code": 404,
"message": "Could not find Application \"project-name\".",
"status": "NOT_FOUND" } }
The value for --project must correspond to a Google Cloud Platform project ID.
It's unclear whether you replaced your actual project ID (NB Project IDs and Project names are distinct properties, see link) with project-name when you pasted your question.
One way to verify that the project exists would be to:
gcloud projects describe [[PROJECT]]
Assuming the project exists, a second consideration is that (since you're not specifying deployables), the command assumes the working directory contains an app.yaml (App Engine app configuration) file.

ERROR: (gcloud.app.deploy) You do not have permission to access app [my-app] (or it may not exist): The caller does not have permission

I am trying to deploy my Google App Engine app through Bitbucket Pipelines. However I'm getting the following permission error while trying to deploy.
This is my bitbucket-pipelines.yml script:
script:
# Install Google App Engine SDK
- curl -o /tmp/google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-155.0.0-linux-x86_64.tar.gz
- tar -xvf /tmp/google-cloud-sdk.tar.gz -C /tmp/
- /tmp/google-cloud-sdk/install.sh -q
- source /tmp/google-cloud-sdk/path.bash.inc
# Authenticating with the service account key file
- echo $GOOGLE_CLIENT_SECRET > ./gcloud-api-key.json
- gcloud auth activate-service-account --key-file gcloud-api-key.json
# Linking to the Google Cloud project
- gcloud config list
- gcloud config set project $CLOUDSDK_CORE_PROJECT
- gcloud app deploy --log-http --verbosity=debug app.yaml
Please find the debug log below.
DEBUG: API endpoint: [https://appengine.googleapis.com/], API version: [v1]
=======================
==== request start ====
uri: https://appengine.googleapis.com/v1/apps/my-app?alt=json
method: GET
== headers start ==
Authorization: Bearer [hidden]
accept: application/json
accept-encoding: gzip, deflate
content-length: 0
user-agent: google-cloud-sdk x_Tw5K8nnjoRAqULM9PFAC2b gcloud/155.0.0 command/gcloud.app.deploy invocation-id/234e7fc5072e448aaa6870de17b900f2 environment/None environment-version/None interactive/False python/2.7.13 (Linux 4.19.43-coreos)
== headers end ==
== body start ==
== body end ==
==== request end ====
---- response start ----
-- headers start --
-content-encoding: gzip
alt-svc: quic=":443"; ma=2592000; v="46,44,43,39"
cache-control: private
content-length: 126
content-type: application/json; charset=UTF-8
date: Sun, 09 Jun 2019 22:39:11 GMT
server: ESF
status: 403
transfer-encoding: chunked
vary: Origin, X-Origin, Referer
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 0
-- headers end --
-- body start --
{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
-- body end --
total round trip time (request+response): 0.389 secs
---- response end ----
----------------------
DEBUG: HttpError accessing <https://appengine.googleapis.com/v1/apps/my-app?alt=json>: response: <{'status': '403', 'content-length': '126', 'x-xss-protection': '0', 'x-content-type-options': 'nosniff', 'transfer-encoding': 'chunked', 'vary': 'Origin, X-Origin, Referer', 'server': 'ESF', '-content-encoding': 'gzip', 'cache-control': 'private', 'date': 'Sun, 09 Jun 2019 22:39:11 GMT', 'x-frame-options': 'SAMEORIGIN', 'alt-svc': 'quic=":443"; ma=2592000; v="46,44,43,39"', 'content-type': 'application/json; charset=UTF-8'}>, content <{
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
>
DEBUG: (gcloud.app.deploy) You do not have permission to access app [my-app] (or it may not exist): The caller does not have permission
Traceback (most recent call last):
File "/tmp/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 712, in Execute
resources = args.calliope_command.Run(cli=self, args=args)
File "/tmp/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 784, in Run
resources = command_instance.Run(args)
File "/tmp/google-cloud-sdk/lib/surface/app/deploy.py", line 61, in Run
args, runtime_builder_strategy=runtime_builder_strategy)
File "/tmp/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 369, in RunDeploy
app = _PossiblyCreateApp(api_client, project)
File "/tmp/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 499, in _PossiblyCreateApp
return api_client.GetApplication()
File "/tmp/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/appengine_api_client.py", line 48, in GetApplication
return requests.MakeRequest(self.client.apps.Get, request)
File "/tmp/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/api/requests.py", line 85, in MakeRequest
raise api_lib_exceptions.HttpException(error, error_message=error_message)
HttpException: You do not have permission to access app [my-app] (or it may not exist): The caller does not have permission
ERROR: (gcloud.app.deploy) You do not have permission to access app [my-app] (or it may not exist): The caller does not have permission
I already set a large list of permission to my service account and I keep getting the same error:
App Engine Admin
App Engine Deployer
App Engine Service Admin
App Engine flexible environment Service Agent
Browser
Cloud Build Editor
Cloud Build Service Agent
Environment and Storage Object Administrator
Compute Admin
Compute Instance Admin (v1)
Compute Storage Admin
Service Account Admin
Storage Admin
Storage Object Admin Viewer
I found this post. Deploy to Google Cloud with bitbucket pipeline
First, you’ll need to create a Google service account key. For more guidance see Google's guide to creating service keys.
open up your terminal
browse to the location of your key file
encode your file in base64 format: base64 -w 0
Note: for some versions of MacOS the -w 0 is not necessary.
copy the output of the command
go to your repository settings in Bitbucket and then Pipelines >
Repository variables
create a new variable named KEY_FILE and paste the encoded service
account credentials.
bitbucket-pipelines.yml
image: node:10.15.1
pipelines:
default:
- step:
name: Build and Test
script:
- npm install
- npm test
- step:
name: Deploy
script:
- pipe: atlassian/google-app-engine-deploy:0.2.1
variables:
KEY_FILE: $KEY_FILE
PROJECT: 'my-project'

Google App Engine Guestbook application gives error

I upload the Google App Engine application which is at the url developers.google.com/appengine/docs/python/memcache/usingmemcache#Memcache
When I run the application on Google App Engine Launcher, it runs but the website shows:
(First error is there us no Python "PIL" module but I am not using image. Could you please suggest what is causing the error?
*** Running dev_appserver with the following flags:
--skip_sdk_update_check=yes --port=13080 --admin_port=8005
Python command: /usr/bin/python2.7
INFO 2014-01-17 20:43:22,217 devappserver2.py:660] Skipping SDK update check.
WARNING 2014-01-17 20:43:22,222 api_server.py:331] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO 2014-01-17 20:43:22,226 api_server.py:138] Starting API server at: localhost:55385
INFO 2014-01-17 20:43:22,230 dispatcher.py:171] Starting module "default" running at: localhost:13080
INFO 2014-01-17 20:43:22,238 admin_server.py:117] Starting admin server at: localhost:8005
ERROR 2014-01-17 20:43:24,601 wsgi.py:262]
Traceback (most recent call last):
File "/Users/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 301, in _LoadHandler
raise err
ImportError: <module 'guestbookw2' from '/Users/guestbookw2/guestbookw2.pyc'> has no attribute application
INFO 2014-01-17 20:43:24,607 module.py:617] default: "GET / HTTP/1.1" 500 -
ERROR 2014-01-17 20:43:24,727 wsgi.py:262]
Traceback (most recent call last):
File "/Users/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 301, in _LoadHandler
raise err
ImportError: <module 'guestbookw12' from '/Users/guestbookw2/guestbookw2.pyc'> has no attribute application
INFO 2014-01-17 20:43:24,732 module.py:617] default: "GET /favicon.ico HTTP/1.1" 500 -
Make sure that you have the following files in the path that you are uploading your application from:
index.yaml (auto-generated; you don't need to add or change anything in here at this point).
favicon.ico (in the correct format; should be 16x16 or 32x32 pixels if I remember correctly).
main.py (mapping all the paths in your web-site; example given below):
from webapp2 import WSGIApplication
from Server import MainRequestHandler
from Server import SomeRequestHandler
from Server import OtherRequestHandler
app = WSGIApplication([
('/' ,MainRequestHandler),
('/abc' ,SomeRequestHandler),
('/def' ,SomeRequestHandler),
('/xyz' ,OtherRequestHandler),
])
app.yaml (with the following contents; using <...> where you need to set a value):
application: <the app-id you chose when use signed in for GAE>
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.1" // you might need to change this as well
Note:
if you wish to avoid handling 'favicon.ico' request, then you must remove the reference in file 'app.yaml'.
Supplemental:
You will need to implement all the request handlers imported in 'main.py'.
In the example above, 'main.py' expects to find them in a Python module named 'Server'.
Each request handler must inherit class RequestHandler, imported from webapp2.
Supplemental #2:
In order to solve the 'PIL' issue (had a similar problem if memory serves correctly), simply install it.
From a Windows command line, enter: pip install pil.

Error running using web.py on Google App Engine - application instance has no __call__ method

I've been trying to use web.py to run a simple web app on Google App Engine but have been running into some pretty basic errors. I've searched over the site and haven't found anything to address my issue. Here is the outline of the code I'm trying to run:
import web
urls = (
"/","Index"
)
app = web.application(urls,globals())
render = web.template.render('pages/', base="layout")
class Index:
def GET(self):
#code...
if __name__ == "__main__":
app.cgirun()
and this is the app.yaml code:
application: #appname
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: home.app
- url: /static
static_dir: static
But then I get this in the log:
2013-08-22 06:11:13 Running command: "['C:\\Python27\\pythonw.exe', 'C:\\Program Files\\Google\\google_appengine\\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=8080', '--admin_port=8000', 'C:\\.....\\root\\home-gae']"
INFO 2013-08-22 06:11:16,956 devappserver2.py:557] Skipping SDK update check.
WARNING 2013-08-22 06:11:16,976 api_server.py:317] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO 2013-08-22 06:11:17,006 api_server.py:138] Starting API server at: http://localhost:64510
INFO 2013-08-22 06:11:17,013 dispatcher.py:164] Starting module "default" running at: http://localhost:8080
INFO 2013-08-22 06:11:17,019 admin_server.py:117] Starting admin server at: http://localhost:8000
ERROR 2013-08-22 10:11:24,303 wsgi.py:235]
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 223, in Handle
result = handler(dict(self._environ), self._StartResponse)
AttributeError: application instance has no __call__ method
INFO 2013-08-22 06:11:24,313 module.py:593] default: "GET / HTTP/1.1" 500 -
The AttributeError is confusing me because there does appear to be a call method in web/application module. Any ideas? Any thoughts would be appreciated.
I found a way to work it out.
import web
urls = (
"/.*", "hello"
)
application = web.application(urls, globals())
#app = web.application(urls, globals())
class hello:
def GET(self):
return "HelloWorld"
#app = app.gaerun()
#app.cgirun()
app = application.wsgifunc()
using "app = application.wsgifunc() ", then the code would work well.
First, there is a little problem with your app.yaml. You need to put your static handler before the catch-all handler:
handlers:
- url: /static
static_dir: static
- url: /.*
script: home.app
Otherwise, you will not be able to serve static files.
To fix your issue with the website not loading, it looks like the development server is trying to treat your CGI app as a WSGI app. Try to fit you home.py file to the official example for web.py on GAE. That is, get rid of the if __name__ == "__main__:" part and simply replace it with:
app = app.gaerun()

Resources