Google App Engine, dev_appserver.py: WindowsError: [Error 2] The system cannot find the file specified - google-app-engine

I'm trying to run the Google App Engine local development server (dev_appserver.py), using the following command:
python3 "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin\dev_appserver.py" "C:\Users\myusername\Desktop\test_gae_python3\app.yaml"
However I get the following exception:
# INFO 2023-02-15 23:27:07,500 devappserver2.py:317] Skipping SDK update check.
# INFO 2023-02-15 23:27:07,720 <string>:384] Starting API server at: http://localhost:50618
# INFO 2023-02-15 23:27:07,747 instance_factory.py:155] Detected python version "Python 3.9.13
# " for runtime "python39" at "python3".
# Actual environment location may have moved due to redirects, links or junctions.
# Requested location: "c:\users\myuser~1\appdata\local\temp\tmp2cocmu\Scripts\python3.exe"
# Actual location: "C:\Users\myusername\AppData\Local\Temp\tmp2cocmu\Scripts\python3.exe"
# INFO 2023-02-15 23:27:17,122 instance_factory.py:312] Using pip to install dependency libraries; pip stdout is redirected to c:\users\myuser~1\appdata\local\temp\tmpsvzpsq
# INFO 2023-02-15 23:27:17,154 instance_factory.py:334] Running c:\users\myuser~1\appdata\local\temp\tmp2cocmu\bin\pip install --upgrade pip
# INFO 2023-02-15 23:27:17,155 stub_util.py:360] Applying all pending transactions and saving the datastore
# INFO 2023-02-15 23:27:17,157 stub_util.py:363] Saving search indexes
# Traceback (most recent call last):
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 109, in <module>
# _run_file(__file__, globals())
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 103, in _run_file
# _execfile(_PATHS.script_file(script_name), globals_)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\dev_appserver.py", line 83, in _execfile
# execfile(fn, scope)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 645, in <module>
# main()
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 633, in main
# dev_server.start(options)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 401, in start
# options.api_host, apiserver.port, wsgi_request_info_)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\dispatcher.py", line 272, in start
# ssl_port)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\dispatcher.py", line 409, in _create_module
# ssl_port=ssl_port)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\module.py", line 1356, in __init__
# super(AutoScalingModule, self).__init__(**kwargs)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\module.py", line 615, in __init__
# self._module_configuration)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\module.py", line 242, in _create_instance_factory
# module_configuration=module_configuration)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\python\instance_factory.py", line 207, in __init__
# self._SetupVirtualenvFromConfiguration()
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\python\instance_factory.py", line 233, in _SetupVirtualenvFromConfiguration
# self._venv_dir, self._OrigRequirementsFile)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\python\instance_factory.py", line 359, in _SetupVirtualenv
# self._RunPipInstall(venv_dir, requirements_file_name)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\python\instance_factory.py", line 335, in _RunPipInstall
# pip_proc = subprocess.Popen(pip_cmd, stdout=pip_out, env=pip_env)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython2\lib\subprocess.py", line 390, in __init__
# errread, errwrite)
# File "C:\Users\myusername\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython2\lib\subprocess.py", line 640, in _execute_child
# startupinfo)
# WindowsError: [Error 2] The system cannot find the file specified
C:\Users\myusername\Desktop\test_gae_python3\app.yaml:
runtime: python39
app_engine_apis: true
service: default
entrypoint: python3 -m app
C:\Users\myusername\Desktop\test_gae_python3\app.py:
print('OK')
Of course this is a minimal scenario to reproduce the problem, my actual application is much more complex.
Environment:
Windows 11 Pro (22621.1265)
Python 3.9.13
Google Cloud SDK 418.0.0
app-engine-python 1.9.101
bq 2.0.85
cloud-datastore-emulator 2.3.0
core 2023.02.13
gsutil 5.20
I have no other versions of Python installed in the system.
I've tried reverting the SDK back to 367.0.0 and I get the same exact exception.
Google Cloud SDK 366.0.0 raises a different exception which I don't think is relevant but I can paste if useful.
Background: I'm trying to migrate a Python 2 server to version 3, but I got stuck at this stage and can't wrap my head around it.

This isn't supported by Google. According to Google documentation
The dev_appserver tool does not support development of Python 3 apps on Windows.
I believe it's because gunicorn doesn't run on Windows. But if you still want to use dev_appserver.py for Python 3 Apps on a Windows machine, you can check out a Patch we created (the patch essentially swaps out Gunicorn for Waitress when running your App on your dev machine)

Related

Kiwi TCMS Python API Connection SSL error

I'm getting following error when I try to run the tcms-api module but following the steps given,
https://tcms-api.readthedocs.io/en/latest/modules/tcms_api.html#module-tcms_api
I'm using python 3 in CentOS, applied our own domain and certificates by mounting the certificates to docker container.
Can you please tell how to solve the SSL Certificate verification failure error?
[root#KiwiTCMS-Testcase-Portal docker-compose]# python3 test-api.py
Traceback (most recent call last):
File "test-api.py", line 5, in <module>
rpc_client = TCMS()
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/tcms_api/__init__.py", line 123, in __init__
config['tcms']['url']).server
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/tcms_api/xmlrpc.py", line 124, in __init__
self.login(username, password, url)
File "/opt/rh/rh-python36/root/usr/lib/python3.6/site-packages/tcms_api/xmlrpc.py", line 131, in login
self.server.Auth.login(username, password)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/xmlrpc/client.py", line 1112, in __call__
return self.__send(self.__name, args)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/xmlrpc/client.py", line 1452, in __request
verbose=self.__verbose
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/xmlrpc/client.py", line 1154, in request
return self.single_request(host, handler, request_body, verbose)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/xmlrpc/client.py", line 1166, in single_request
http_conn = self.send_request(host, handler, request_body, verbose)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/xmlrpc/client.py", line 1279, in send_request
self.send_content(connection, request_body)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/xmlrpc/client.py", line 1309, in send_content
connection.endheaders(request_body)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/http/client.py", line 1282, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/http/client.py", line 1042, in _send_output
self.send(msg)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/http/client.py", line 980, in send
self.connect()
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/http/client.py", line 1448, in connect
server_hostname=server_hostname)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/ssl.py", line 817, in __init__
self.do_handshake()
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/ssl.py", line 1077, in do_handshake
self._sslobj.do_handshake()
File "/opt/rh/rh-python36/root/usr/lib64/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)
Introducing the following line fix the issue,
import ssl
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
# Legacy Python that doesn't verify HTTPS certificates by default
pass
else:
# Handle target environment that doesn't support HTTPS verification
ssl._create_default_https_context = _create_unverified_https_context
I see that you are using Python 3.6 from RedHat's SoftwareCollections. That version contains a bug (or arguably a security feature) which doesn't respect settings documented in upstream Python which allow you to accept untrusted SSL certificates. There are lots of these things reported on bugzilla.redhat.com but I don't think they will change it!
This is how we do it in our test suite:
https://github.com/kiwitcms/tcms-api/blob/master/tests/krb5/integration_test.py#L18

What should go in the Dockerfile when using Rasa with Google Cloud Platform

I’m using Google Cloud Platform and Google App Engine (flexible) for my Rasa Opensource chatbot.
I've downloaded the Google Cloud SDK to my local machine and deployed the chatbot using gcloud app deploy to App Engine (I think I'm right that this creates a docker image).
App Engine requires a Dockerfile and an app.yaml file. I just wasn't sure what should go in the Dockerfile. And having some trouble point to the model endpoint where it doesn't think its a zip file.
The Dockerfile looks like:
FROM rasa/rasa
ENV BOT_ENV=production
COPY . /var/www
WORKDIR /var/www
RUN pip install rasa
ENTRYPOINT [ "rasa", "run", "-m", "./models", "-vv", "--enable-api", "--endpoints", "endpoints.yml", "--credentials", "credentials.yml", "-p", "8080"]
C:\Users\xxxxxxxx\Desktop\xxxxxxxxx>gcloud app deploy --version chatbot15
Services to deploy:
descriptor: [C:\Users\xxxxxx\Desktop\xxxxxxxxx\app.yaml]
source: [C:\Users\xxxxxx\Desktop\xxxxxxxx]
target project: [xxxxx-xxxxxxx]
target service: [default]
target version: [chatbot15]
target url: [https://xxxxxxxx.appspot.com]
Do you want to continue (Y/n)? y
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [.
To see logs in the Cloud Console: https://console.cloud.google.com/gcr/builds/xxxxxx41f1f-c289-xxxxxxx-9ba1-xxxxxxxxxxx]
------------------------------------------------- REMOTE BUILD OUTPUT --------------------------------------------------
starting build "xxxxxx41f1f-c289-xxxxxxx-9ba1-xxxxxxxxxxx]"
FETCHSOURCE
Fetching storage object: gs://staging.xxxxxxxxxx.appspot.com/us.gcr.io/xxxxxxxxxx/appengine/default.chatbot15:latest#1xxxxxxxxxxx0
Copying gs://staging.xxxxxxxxxxx.appspot.com/us.gcr.io/xxxxxxxxxx/appengine/default.chatbot15:latest#158xxxxxxxxxx2560...
\ [1 files][ 24.3 MiB/ 24.3 MiB]
Operation completed over 1 objects/24.3 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
Sending build context to Docker daemon 38.15MB
Step 1/6 : FROM rasa/rasa
latest: Pulling from rasa/rasa
Digest: sha256:cc6a48c7cxxxc8f1c8c3bxxxxxxxxxxxxxxxxef266a58121f41e22b418c6a
Status: Downloaded newer image for rasa/rasa:latest
---> fcf204982b0f
Step 2/6 : ENV BOT_ENV=production
---> Running in 708a75c57f16
Removing intermediate container 708a75c57f16
---> 780c38217741
Step 3/6 : COPY . /var/www
---> a32cfeb03a84
Step 4/6 : WORKDIR /var/www
---> Running in 4f4f0446c8a4
Removing intermediate container 4f4f0446c8a4
---> 1751f3ffc062
Step 5/6 : RUN pip install rasa
---> Running in b70c61ca4670
[91mWARNING: The directory '/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
[0mRemoving intermediate container b70cxxxx670
---> 3e8xxx0f91c
Step 6/6 : ENTRYPOINT [ "rasa", "run", "-m", "./models", "-vv", "--enable-api", "--endpoints", "endpoints.yml", "--credentials", "credentials.yml", "-p", "8080"]
---> Running in 4xxxxxx6
Removing intermediate container 4xxxxxxxxxx6
---> 6fxxxxxxxxx30
Successfully built 6xxxxxxxxxxx30
Successfully tagged us.gcr.io/xxxxxxxxxx/appengine/default.chatbot15:latest
PUSH
Pushing us.gcr.io/xxxxxxxxxxx/appengine/default.chatbot15:latest
The push refers to repository [us.gcr.io/xxxxxxxxxxx/appengine/default.chatbot15]
0da5206fa56e: Pushed
latest: digest: sha256:d1cxxxxxxxxxxxxxxxxxxxxxxxx724xxxxxx size: 2837
DONE
------------------------------------------------------------------------------------------------------------------------
Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
2020-01-27 19:54:37 DEBUG rasa.core.utils - Available web server routes:
/conversations/<conversation_id>/messages POST add_message
/conversations/<conversation_id>/tracker/events POST append_events
/webhooks/rasa GET custom_webhook_RasaChatInput.health
/webhooks/rasa/webhook POST custom_webhook_RasaChatInput.receive
/webhooks/rest GET custom_webhook_RestInput.health
/webhooks/rest/webhook POST custom_webhook_RestInput.receive
/model/test/intents POST evaluate_intents
/model/test/stories POST evaluate_stories
/conversations/<conversation_id>/execute POST execute_action
/domain GET get_domain
/socket.io GET handle_request
/ GET hello
/model PUT load_model
/model/parse POST parse
/conversations/<conversation_id>/predict POST predict
/conversations/<conversation_id>/tracker/events PUT replace_events
/conversations/<conversation_id>/story GET retrieve_story
/conversations/<conversation_id>/tracker GET retrieve_tracker
/webhooks/socketio GET socketio_webhook.health
/status GET status
/model/predict POST tracker_predict
/model/train POST train
/conversations/<conversation_id>/trigger_intent POST trigger_intent
/model DELETE unload_model
/version GET version
2020-01-27 19:54:37 INFO root - Starting Rasa server on http://localhost:8080
2020-01-27 19:54:37 DEBUG rasa.core.utils - Using the default number of Sanic workers (1).
2020-01-27 19:54:37 INFO root - Enabling coroutine debugging. Loop id 94796527495608.
2020-01-27 19:54:37 DEBUG rasa.model - Extracted model to '/tmp/tmpq4hewp3_'.
2020-01-27 19:54:41.930821: E tensorflow/stream_executor/cuda/cuda_driver.cc:318] failed call to cuInit: UNKNOWN ERROR (303)
2020-01-27 19:54:42 DEBUG rasa.core.tracker_store - Connected to InMemoryTrackerStore.
2020-01-27 19:54:42 DEBUG rasa.core.lock_store - Connected to lock store 'InMemoryLockStore'.
2020-01-27 19:54:42 DEBUG rasa.core.nlg.generator - Instantiated NLG to 'TemplatedNaturalLanguageGenerator'.
2020-01-27 19:54:42 DEBUG rasa.core.agent - Requesting model from server http://xxxxxxxxxxx.appspot.com/?hl=en-GB/models/20200123-205743.tar.gz...
2020-01-27 19:54:42 ERROR rasa.core.agent - Could not load model due to File is not a zip file.
[2020-01-27 19:54:42 +0000] [1] [ERROR] Experienced exception while trying to serve
Traceback (most recent call last):
File "/build/lib/python3.6/site-packages/rasa/utils/io.py", line 195, in unarchive
tar = tarfile.open(fileobj=IOReader(byte_array))
File "/usr/local/lib/python3.6/tarfile.py", line 1576, in open
raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/build/lib/python3.6/site-packages/sanic/app.py", line 1133, in run
serve(**server_settings)
File "/build/lib/python3.6/site-packages/sanic/server.py", line 857, in serve
trigger_events(before_start, loop)
File "/build/lib/python3.6/site-packages/sanic/server.py", line 634, in trigger_events
loop.run_until_complete(result)
File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
File "/build/lib/python3.6/site-packages/rasa/core/run.py", line 247, in load_agent_on_start
action_endpoint=endpoints.action,
File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 248, in load_agent
model_server,
File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 64, in load_from_server
await _update_model_from_server(model_server, agent)
File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 122, in _update_model_from_server
model_server, agent.fingerprint
File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 180, in _pull_model_and_fingerprint
rasa.utils.io.unarchive(await resp.read(), model_directory)
File "/build/lib/python3.6/site-packages/rasa/utils/io.py", line 200, in unarchive
zip_ref = zipfile.ZipFile(IOReader(byte_array))
File "/usr/local/lib/python3.6/zipfile.py", line 1131, in __init__
self._RealGetContents()
File "/usr/local/lib/python3.6/zipfile.py", line 1198, in _RealGetContents
raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
Traceback (most recent call last):
File "/build/lib/python3.6/site-packages/rasa/utils/io.py", line 195, in unarchive
tar = tarfile.open(fileobj=IOReader(byte_array))
File "/usr/local/lib/python3.6/tarfile.py", line 1576, in open
raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/build/bin/rasa", line 8, in <module>
sys.exit(main())
File "/build/lib/python3.6/site-packages/rasa/__main__.py", line 76, in main
cmdline_arguments.func(cmdline_arguments)
File "/build/lib/python3.6/site-packages/rasa/cli/run.py", line 83, in run
rasa.run(**vars(args))
File "/build/lib/python3.6/site-packages/rasa/run.py", line 56, in run
**kwargs,
File "/build/lib/python3.6/site-packages/rasa/core/run.py", line 206, in serve_application
endpoints.lock_store if endpoints else None
File "/build/lib/python3.6/site-packages/sanic/app.py", line 1133, in run
serve(**server_settings)
File "/build/lib/python3.6/site-packages/sanic/server.py", line 857, in serve
trigger_events(before_start, loop)
File "/build/lib/python3.6/site-packages/sanic/server.py", line 634, in trigger_events
loop.run_until_complete(result)
File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
File "/build/lib/python3.6/site-packages/rasa/core/run.py", line 247, in load_agent_on_start
action_endpoint=endpoints.action,
File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 248, in load_agent
model_server,
File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 64, in load_from_server
await _update_model_from_server(model_server, agent)
File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 122, in _update_model_from_server
model_server, agent.fingerprint
File "/build/lib/python3.6/site-packages/rasa/core/agent.py", line 180, in _pull_model_and_fingerprint
rasa.utils.io.unarchive(await resp.read(), model_directory)
File "/build/lib/python3.6/site-packages/rasa/utils/io.py", line 200, in unarchive
zip_ref = zipfile.ZipFile(IOReader(byte_array))
File "/usr/local/lib/python3.6/zipfile.py", line 1131, in __init__
self._RealGetContents()
File "/usr/local/lib/python3.6/zipfile.py", line 1198, in _RealGetContents
raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
Thanks.
My dockerfile looks like this:
FROM rasa/rasa
USER root
ENV BOT_ENV=development
COPY . /var/www
WORKDIR /var/www
RUN pip install --no-cache-dir phonenumbers pgeocode
#ENTRYPOINT ["rasa", "run", "-vv", "--enable-api", "actions"]
#ENTRYPOINT ["rasa", "run", "-vv", "--enable-api", "-m", "models", "--cors", "*", "--endpoints", "endpoints.yml", "--credentials", "credentials.yml", "-p", "8080"]
ENTRYPOINT ["rasa", "run", "-p", "8080", "--debug", "--enable-api", "--cors", "*"]
#ENTRYPOINT["rasa", "run", "-p", "8080"]
I have many options because I've been trying different ones as I don't manage to get my bot to take actions on the received messages. With the last one that is commented out, I get to see some HTTP 204 responses from twilio, which I think is good as at least I'm not receiving error responses anymore.
I'm still trying to figure out why my domain and policy are not being taken into account, as I'm getting these messages in the console:
2020-02-25 03:45:47 default[botgister-0] /build/lib/python3.6/site-packages/rasa/utils/common.py:351: UserWarning: No policy ensemble or domain set. Skipping action prediction and execution.
2020-02-25 03:45:47 default[botgister-0] More info at https://rasa.com/docs/rasa/core/policies/
Well, hope this helps.

OSX dev_appserver.py file not accessible: '/System/Library/CoreServices/SystemVersion.plist'

I did a gcloud components update 2 days ago and started getting this error when i run dev_appserver.py
(venv) myusername#mymachine:~/projects/myproject$ dev_appserver.py ./ --host 0.0.0.0 --port 8002 --enable_console --env_var GCS_TOKEN=ya29........YJDQAnp772B0
INFO 2019-03-13 23:45:31,205 devappserver2.py:278] Skipping SDK update check.
INFO 2019-03-13 23:45:31,268 api_server.py:275] Starting API server at: http://localhost:64587
INFO 2019-03-13 23:45:31,319 dispatcher.py:256] Starting module "default" running at: http://0.0.0.0:8002
INFO 2019-03-13 23:45:31,325 admin_server.py:150] Starting admin server at: http://localhost:8000
/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/mtime_file_watcher.py:182: UserWarning: There are too many files in your application for changes in all of them to be monitored. You may have to restart the development server to see some changes to your files.
'There are too many files in your application for '
INFO 2019-03-13 23:45:35,237 instance.py:294] Instance PID: 29760
appengine_config
requests.__version__ 2.21.0
Appengine config done
4
ERROR 2019-03-13 23:45:35,986 wsgi.py:263]
Traceback (most recent call last):
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/Users/myusername/projects/myproject/main.py", line 34, in <module>
from bp_includes.lib.error_handler import handle_error
File "/Users/myusername/projects/myproject/bp_includes/lib/error_handler.py", line 15, in <module>
from bp_includes.lib import jinja_bootstrap
File "/Users/myusername/projects/myproject/bp_includes/lib/jinja_bootstrap.py", line 7, in <module>
from src.handlers.utils import ordinal
File "/Users/myusername/projects/myproject/src/handlers/utils.py", line 14, in <module>
from lib.pytz.gae import pytz
File "/Users/myusername/projects/myproject/lib/pytz/__init__.py", line 29, in <module>
from pkg_resources import resource_stream
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 1022, in <module>
class Environment(object):
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 1025, in Environment
def __init__(self, search_path=None, platform=get_supported_platform(),
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 263, in get_supported_platform
plat = get_build_platform()
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 472, in get_build_platform
INFO 2019-03-13 23:45:36,002 module.py:861] default: "GET /_ah/warmup HTTP/1.1" 500 -
version = _macosx_vers()
File "/Users/myusername/projects/myproject/lib/pkg_resources/__init__.py", line 439, in _macosx_vers
version = platform.mac_ver()[0]
File "/Users/myusername/projects/myproject/venv/lib/python2.7/platform.py", line 764, in mac_ver
info = _mac_ver_xml()
File "/Users/myusername/projects/myproject/venv/lib/python2.7/platform.py", line 741, in _mac_ver_xml
pl = plistlib.readPlist(fn)
File "/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plistlib.py", line 75, in readPlist
pathOrFile = open(pathOrFile)
File "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/stubs.py", line 284, in __init__
raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: '/System/Library/CoreServices/SystemVersion.plist'
I originally installed gcloud with brew cask install google-cloud-sdk in case that's relevant
It looks like the problem was introduced in gcloud 238.0.0 probably with gcloud app Python Extensions 1.9.84. You can downgrade gcloud to lower version with:
gcloud components update --version 237.0.0
I got it to work by doing the following in appengine_config.py, but I'm hoping that someone has a better solution
try:
from google.appengine.tools.devappserver2.python.runtime.stubs import FakeFile
FakeFile._allowed_dirs.update(['/System/Library/CoreServices/'])
except ImportError:
pass
you can delete the lib folder where you requirements are installed and reinstall it worked for me
pip install -t "lib" -r requirements.txt

Running locally with GAE Python second generation

I've been using GAE/P 1st gen for many years and am making the jump to my first GAE/P 2nd gen project.
I'm trying to run it locally like I did with dev_appserver.py for 1st gen apps, but the docs are very confusing in this respect.
I can run Flask on its own (python main.py) but static files don't work (since Flask knows nothing about app.yaml) and the datastore won't work either.
The GAE docs say that dev_appserver.py should work for 2nd gen (except on Windows but I'm on Mac) but when I run it, I get the error below.
This happens when I run dev_appserver.py with Python 2 or 3. I've also set CLOUDSDK_PYTHON to my Python 2 binary as instructed.
So how the heck can I run my GAE/P 2nd gen project locally in way that static files and the datastore work?!?
$ python ~/google-cloud-sdk/bin/dev_appserver.py --application=myapp --support_datastore_emulator=False ./app.yaml
INFO 2019-02-12 00:39:21,885 devappserver2.py:278] Skipping SDK update check.
INFO 2019-02-12 00:39:23,128 api_server.py:275] Starting API server at: http://localhost:51187
INFO 2019-02-12 00:39:23,139 instance_factory.py:71] Detected Python 3.6.5
INFO 2019-02-12 00:39:24,459 instance_factory.py:205] Using pip to install dependency libraries; pip stdout is redirected to /var/folders/yd/xr84fg0946l72fp_cc6j9l540000gr/T/tmpj3SEUZ
INFO 2019-02-12 00:39:24,459 instance_factory.py:211] Running /var/folders/yd/xr84fg0946l72fp_cc6j9l540000gr/T/tmpLtysT3/bin/pip install --upgrade pip
INFO 2019-02-12 00:39:24,469 stub_util.py:357] Applying all pending transactions and saving the datastore
INFO 2019-02-12 00:39:24,469 stub_util.py:360] Saving search indexes
Traceback (most recent call last):
File "/.../google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 96, in <module>
_run_file(__file__, globals())
File "/.../google-cloud-sdk/platform/google_appengine/dev_appserver.py", line 90, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 600, in <module>
main()
File "/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 588, in main
dev_server.start(options)
File "/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 360, in start
options.api_host, apiserver.port, wsgi_request_info_)
File "/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/dispatcher.py", line 248, in start
ssl_port)
File "/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/dispatcher.py", line 384, in _create_module
ssl_port=ssl_port)
File "/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 1309, in __init__
super(AutoScalingModule, self).__init__(**kwargs)
File "/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 598, in __init__
self._module_configuration)
File "/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/module.py", line 231, in _create_instance_factory
module_configuration=module_configuration)
File "/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/instance_factory.py", line 98, in __init__
self._SetupVirtualenvFromConfiguration()
File "/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/instance_factory.py", line 143, in _SetupVirtualenvFromConfiguration
self._venv_dir, requirements_file.name)
File "/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/instance_factory.py", line 228, in _SetupVirtualenv
cls._RunPipInstall(venv_dir, requirements_file_name)
File "/.../google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/instance_factory.py", line 212, in _RunPipInstall
pip_proc = subprocess.Popen(pip_cmd, stdout=pip_out)
File "/usr/local/Cellar/python#2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 394, in __init__
errread, errwrite)
File "/usr/local/Cellar/python#2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1047, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
After a good night's sleep, I was able to figure out the problem...
I was running dev_appserver.py from within my virtual environment. For some reason, this prevented dev_appserver.py from being able to find pip (needed to install the packages in my requirements.txt).
Exiting my virtual environment before running dev_appserver.py fixed the problem.

gcloud deploy error: Image with tag google/docker-registry was not found

I'm trying to deploy this project https://github.com/GoogleCloudPlatform/appengine-nodejs-quickstart by using this command
gcloud --project poised-graph-758 preview app deploy --server preview.appengine.google.com .
but i get this error:
Updating module [default] from file [/Users/kannix/Desktop/tmp/appengine-nodejs-quickstart/app.yaml]
11:36 PM Host: preview.appengine.google.com
{bucket: vm-containers.poised-graph-758.appspot.com, path: /containers}
Traceback (most recent call last):
File "/Users/kannix/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 153, in <module>
main()
File "/Users/kannix/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 149, in main
_cli.Execute()
File "/Users/kannix/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 381, in Execute
post_run_hooks=self.__post_run_hooks, kwargs=kwargs)
File "/Users/kannix/google-cloud-sdk/./lib/googlecloudsdk/calliope/frontend.py", line 274, in _Execute
pre_run_hooks=pre_run_hooks, post_run_hooks=post_run_hooks)
File "/Users/kannix/google-cloud-sdk/./lib/googlecloudsdk/calliope/backend.py", line 887, in Run
result = command_instance.Run(args)
File "/Users/kannix/google-cloud-sdk/./lib/googlecloudsdk/calliope/exceptions.py", line 78, in TryFunc
return func(*args, **kwargs)
File "/Users/kannix/google-cloud-sdk/lib/googlecloudsdk/appengine/app_commands/deploy.py", line 154, in Run
self.__Run(args, project, deployables)
File "/Users/kannix/google-cloud-sdk/lib/googlecloudsdk/appengine/app_commands/deploy.py", line 207, in __Run
info.runtime, path, bucket)
File "/Users/kannix/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/images/push.py", line 134, in BuildAndPushDockerImage
boto_path=config.BOTO_PATH)) as r:
File "/Users/kannix/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/images/registry.py", line 148, in __enter__
self.Start()
File "/Users/kannix/google-cloud-sdk/./lib/googlecloudsdk/appengine/lib/images/registry.py", line 97, in Start
self._registry.Start()
File "/Users/kannix/google-cloud-sdk/platform/google_appengine/google/appengine/tools/docker/containers.py", line 480, in Start
self._image.Build()
File "/Users/kannix/google-cloud-sdk/platform/google_appengine/google/appengine/tools/docker/containers.py", line 309, in Build
raise ImageError('Image with tag %s was not found' % self.tag)
google.appengine.tools.docker.containers.ImageError: Image with tag google/docker-registry was not found
I tried to omit the --server preview.appengine.google.com parameter but it results in the same error
You need to pull the google/docker-registry image to resolve this error:
docker pull google/docker-registry
Note: if you receive the following error when trying to redeploy:
docker.docker.errors.APIError: 500 Server Error: Internal Server Error ("Invalid registry endpoint https://192.168.59.103:49153/v1/: Get https://192.168.59.103:49153/v1/_ping: EOF. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry 192.168.59.103:49153` to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/192.168.59.103:49153/ca.crt")
Ensure that your docker daemon has been setup with the 'insecure registry' option (you will need to re-pull the google/docker-registry after the following steps) . You can do this with the following, (which was an answer on https://github.com/docker/docker/issues/8887):
$ boot2docker delete #removes old image
$ rm -f ~/.ssh/id_boot2docker* # remove old keys
$ boot2docker init #generates new keys, cert
$ boot2docker up
$ boot2docker ssh
$ # add EXTRA_ARGS="--insecure-registry <YOUR INSECURE HOST>"
$ # to /var/lib/boot2docker/profile
$ sudo /etc/init.d/docker restart
Try running this first:
gcloud preview app setup-managed-vms
Also make sure you're running Docker 1.3.0, not 1.3.1.
Docker 1.4.0 also doesn't work at this moment.
Deploying with --server preview.appengine.google.com did it for me.

Resources