I am using a normal command to upload my application in Google App Engine (Python 2.7, SDK 1.8.9):
appcfg.py --oauth2 update .
But after a refactoring in my project there is an error in a regular expression for app.yaml (here is the code)
The error is:
02:00 AM Application: sandengine; version: dev
02:00 AM Host: appengine.google.com
02:00 AM Starting update of app: sandengine, version: dev
02:00 AM Getting current resource limits.
02:00 AM Scanning files on local disk.
Traceback (most recent call last):
File "/usr/local/bin/appcfg.py", line 199, in <module>
run_file(__file__, globals())
File "/usr/local/bin/appcfg.py", line 195, in run_file
execfile(script_path, globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 4933, in <module>
main(sys.argv)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 4924, in main
result = AppCfgApp(argv).Run()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 2648, in Run
self.action(self)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 4604, in __call__
return method()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 3419, in Update
self._UpdateWithParsedAppYaml(appyaml, self.basepath)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 3466, in _UpdateWithParsedAppYaml
self.UpdateVersion(rpcserver, basepath, appyaml, APP_YAML_FILENAME)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 3357, in UpdateVersion
return appversion.DoUpload(paths, openfunc)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 2143, in DoUpload
self._AddFilesThatAreSmallEnough(paths, openfunc)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 2211, in _AddFilesThatAreSmallEnough
file_classification = FileClassification(self.config, path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 257, in __init__
self.__static_mime_type = self.__GetMimeTypeIfStaticFile(config, filename)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/appcfg.py", line 287, in __GetMimeTypeIfStaticFile
if re.match(regex, filename):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 137, in match
return _compile(pattern, flags).match(string)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 242, in _compile
raise error, v # invalid expression
sre_constants.error: bogus escape: '\\1'
It is a regular expression error, where in upload: you can't use \1 or \2
Here is the fix: https://github.com/coto/gae-boilerplate/commit/7fbcba2cb217f8ccd8ced7bfe634b4aceaf616c6
Instead of "dev" as the version number, try putting in an actual number :)
dev is a reserved keyword. Change the version and instead of dev use a number or a lowercase string.
It Worked for me
Its pretty easy to figure out what file of your app.yaml is the problem by putting a print here.
/home/nburn42/Apps/google_appengine/google/appengine/tools/appcfg.py
line 315
It is maybe a bit overkill but it will definitely get you unstuck.
Related
Hello fellow linux-users!
After tweaking my gpu with GWE (greenwithenvy) the system frooze and I had to do a hard reset.
Now the GWE-app won'r run due to a malformed sqlite3 db.
What I've tried:
Total purge of sqlite3-, flatpak-, gwe-files.
Reinstalled sqlite3-paks, flatpak-, gwe-files
My question is:
Where is this db stored on the computer? I really don't know where to look!
When I execute the command:
flatpak run com.leinardi.gwe -v
I get the following:
CRITICAL: Uncaught exception
Traceback (most recent call last):
File "/app/lib/python3.7/site-packages/peewee.py", line 3099, in execute_sql
cursor.execute(sql, params or ())
sqlite3.DatabaseError: database disk image is malformed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/bin/gwe", line 54, in <module>
__main__.main()
File "/app/lib/python3.7/site-packages/gwe/__main__.py", line 100, in main
_init_database()
File "/app/lib/python3.7/site-packages/gwe/__main__.py", line 94, in _init_database
Setting
File "/app/lib/python3.7/site-packages/peewee.py", line 3286, in create_tables
model.create_table(**options)
File "/app/lib/python3.7/site-packages/peewee.py", line 6595, in create_table
cls._schema.create_all(safe, **options)
File "/app/lib/python3.7/site-packages/peewee.py", line 5731, in create_all
self.create_table(safe, **table_options)
File "/app/lib/python3.7/site-packages/peewee.py", line 5586, in create_table
self.database.execute(self._create_table(safe=safe, **options))
File "/app/lib/python3.7/site-packages/peewee.py", line 3112, in execute
return self.execute_sql(sql, params, commit=commit)
File "/app/lib/python3.7/site-packages/peewee.py", line 3106, in execute_sql
self.commit()
File "/app/lib/python3.7/site-packages/peewee.py", line 2873, in __exit__
reraise(new_type, new_type(exc_value, *exc_args), traceback)
File "/app/lib/python3.7/site-packages/peewee.py", line 183, in reraise
raise value.with_traceback(tb)
File "/app/lib/python3.7/site-packages/peewee.py", line 3099, in execute_sql
cursor.execute(sql, params or ())
peewee.DatabaseError: database disk image is malformed
Thank you!
I did a simple search via the terminal!
Command:
find . -type f -name "*.db"
Result:
./.var/app/com.leinardi.gwe/config/gwe/gwe.db
I just deleted it! Problem solved!
I try to download my code from google using:
appcfg.py download_app -A "canada-math" ./trunk3
I have the old appengine installed under my home dir, which you can see in the error output below.
appcfg.py download_app -A "canada-math" ./trunk3
I get this:
stephen#stephen-AO725:~/webprog$ appcfg.py download_app -A "canada-math" ./trunk3
05:06 PM Host: appengine.google.com
05:06 PM Fetching file list...
Traceback (most recent call last):
File "/home/stephen/webprog/google_appengine/appcfg.py", line 171, in <module>
run_file(__file__, globals())
File "/home/stephen/webprog/google_appengine/appcfg.py", line 167, in run_file
execfile(script_path, globals_)
File "/home/stephen/webprog/google_appengine/google/appengine/tools/appcfg.py", line 4282, in <module>
main(sys.argv)
File "/home/stephen/webprog/google_appengine/google/appengine/tools/appcfg.py", line 4273, in main
result = AppCfgApp(argv).Run()
File "/home/stephen/webprog/google_appengine/google/appengine/tools/appcfg.py", line 2409, in Run
self.action(self)
File "/home/stephen/webprog/google_appengine/google/appengine/tools/appcfg.py", line 4003, in __call__
return method()
File "/home/stephen/webprog/google_appengine/google/appengine/tools/appcfg.py", line 2861, in DownloadApp
DoDownloadApp(rpcserver, out_dir, app_id, module, app_version)
File "/home/stephen/webprog/google_appengine/google/appengine/tools/appcfg.py", line 1373, in DoDownloadApp
result = rpcserver.Send('/api/files/list', **url_args)
File "/home/stephen/webprog/google_appengine/google/appengine/tools/appengine_rpc.py", line 393, in Send
f = self.opener.open(req)
File "/usr/lib/python2.7/urllib2.py", line 429, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 447, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1241, in https_open
context=self._context)
TypeError: do_open() got an unexpected keyword argument 'context'
The simplest fix is likely to download the source code by running appcfg.py in Cloud Shell. That will ensure that your appcfg.py and Python versions are compatible with the App Engine API.
Depending on your specific versions of appcfg and Python, you may have a version mismatch. Also keep in mind that appcfg is deprecated. See also:
SDK is incompatible with python 2.7.9
Deploying Google app engine with python failed
When I follow Google-Developers' tutorial for creating a simple application in Go using App Engine SDK for Go, while running the command
goapp serve
I receive the following error:
Traceback (most recent call last):
File "/home/kamal/go_appengine/dev_appserver.py", line 82, in <module>
_run_file(__file__, globals())
File "/home/kamal/go_appengine/dev_appserver.py", line 78, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 1001, in <module>
main()
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 994, in main
dev_server.start(options)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 754, in start
options.config_paths)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 632, in __init__
module_configuration = ModuleConfiguration(config_path)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 97, in __init__
self._config_path)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 316, in _parse_configuration
config, files = appinfo_includes.ParseAndReturnIncludePaths(f)
File "/home/kamal/go_appengine/google/appengine/api/appinfo_includes.py", line 81, in ParseAndReturnIncludePaths
appyaml = appinfo.LoadSingleAppInfo(appinfo_file)
File "/home/kamal/go_appengine/google/appengine/api/appinfo.py", line 1873, in LoadSingleAppInfo
listener.Parse(app_info)
File "/home/kamal/go_appengine/google/appengine/api/yaml_listener.py", line 226, in Parse
self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
File "/home/kamal/go_appengine/google/appengine/api/yaml_listener.py", line 177, in _HandleEvents
raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError: Unknown url handler type.
URLMap
auth_fail_action=redirect
static_dir=None
secure=default
http_headers=None
url=/.*
static_files=None
expiration=None
upload=None
api_endpoint=None
script=None
application_readable=None
position=None
login=optional
mime_type=None
require_matching_file=None
in "myapp/app.yaml", line 8, column 1
error while running dev_appserver.py: exit status 1
I don't know how to debug it. Just a hint would be sufficient.
Also, can it be because I have no web server installed? Do I have to install Apache or Nginx for goapp serve or go handles the server stuff itself?
The problem was indentation of script in handlers in .yaml file.
I initially did it like this:
handlers:
- url: /.*
script: _go_app
While it should be:
handlers:
- url: /.*
script: _go_app
It works now!
Good day to all. I am using Google App Engine 1.6.2 , Python 2.7 ,Windows 7x64, i created an application..uploded it...it was successfully working for about a weak. But when i was trying to make an update this morning, luncher gave me this error:
2012-02-20 12:26:41 Running command: "['C:\\Python27\\pythonw.exe', '-u', 'C:\\Program Files (x86)\\Google\\google_appengine\\appcfg.py', '--no_cookies', u'--email=myemail#gmail.com', '--passin', 'update', 'D:\\Dropbox\\Google\\handmade']"
Application: bubonchikhub; version: 1
Host: appengine.google.com
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 101, in <module>
run_file(__file__, globals())
File "C:\Program Files (x86)\Google\google_appengine\appcfg.py", line 97, in run_file
execfile(script_path, globals_)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3935, in <module>
main(sys.argv)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3926, in main
result = AppCfgApp(argv).Run()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 2497, in Run
self.action(self)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 3692, in __call__
return method()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 2915, in Update
self.UpdateVersion(rpcserver, self.basepath, appyaml)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 2897, in UpdateVersion
updatecheck.CheckForUpdates()
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appcfg.py", line 572, in CheckForUpdates
runtime=self.config.runtime)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\appengine_rpc.py", line 365, in Send
f = self.opener.open(req)
File "C:\Python27\lib\urllib2.py", line 394, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 412, in _open
'_open', req)
File "C:\Python27\lib\urllib2.py", line 372, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1207, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "C:\Program Files (x86)\Google\google_appengine\lib\fancy_urllib\fancy_urllib\__init__.py", line 363, in do_open
url_error.reason.args[1])
fancy_urllib.InvalidCertificateException: Host 127.0.0.1:8888 returned an invalid certificate (_ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed):
To learn more, see http://code.google.com/appengine/kb/general.html#rpcssl
2012-02-20 12:26:43 (Process exited with code 1)
You can close this window now.
You can close this window now.
Can anyone help how to fix this?
Thnx in advance
Your request might be going through a local proxy.
Upgrading to Python 2.7.9 fixed this for me.
You need to paste your proxy's certification to the end of google_appengine/lib/cacerts/cacerts.txt
This does seem to be related to proxy servers, when I run fiddler and try to deploy I get this error. When I shut it down deployment works fine.
You will get an invalid certificate error like
fancy_urllib.InvalidCertificateException: Host 127.0.0.1:8888 returned an invalid certificate (_ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed):
So turn of the proxy server (assuming this is your issue) you are running and and the run the appcfg deploy!
A simple GAE application threw the following error on self.jinja2.render_template() on only one computer, but not on any others (both macs and pcs):
ERROR 2012-02-14 21:54:04,987 webapp2.py:1528] [Errno 13] file not accessible: 'templates/test.html'
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1077, in __call__
return handler.dispatch()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 545, in dispatch
return method(*args, **kwargs)
File "/Users/scott/svn/GAE_branches/sample_broken_app/handlers.py", line 21, in get
self.render_response('test.html', **context)
File "/Users/scott/svn/GAE_branches/sample_broken_app/handlers.py", line 14, in render_response
rv = self.jinja2.render_template(_template, **context)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2_extras/jinja2.py", line 158, in render_template
return self.environment.get_template(_filename).render(**context)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/jinja2/jinja2/environment.py", line 719, in get_template
return self._load_template(name, self.make_globals(globals))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/jinja2/jinja2/environment.py", line 693, in _load_template
template = self.loader.load(self, name, globals)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/jinja2/jinja2/loaders.py", line 115, in load
source, filename, uptodate = self.get_source(environment, name)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/jinja2/jinja2/loaders.py", line 165, in get_source
f = open_if_exists(filename)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/jinja2/jinja2/utils.py", line 224, in open_if_exists
return open(filename, mode)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 592, in __init__
raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: 'templates/test.html'
ERROR 2012-02-14 21:54:04,991 wsgi.py:205]
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 193, in Handle
result = handler(self._environ, self._StartResponse)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1519, in __call__
response = self._internal_error(e)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1511, in __call__
rv = self.handle_exception(request, response, e)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1505, in __call__
rv = self.router.dispatch(request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1253, in default_dispatcher
return route.handler_adapter(request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1077, in __call__
return handler.dispatch()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 547, in dispatch
return self.handle_exception(e, self.app.debug)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 545, in dispatch
return method(*args, **kwargs)
File "/Users/scott/svn/GAE_branches/sample_broken_app/handlers.py", line 21, in get
self.render_response('test.html', **context)
File "/Users/scott/svn/GAE_branches/sample_broken_app/handlers.py", line 14, in render_response
rv = self.jinja2.render_template(_template, **context)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2_extras/jinja2.py", line 158, in render_template
return self.environment.get_template(_filename).render(**context)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/jinja2/jinja2/environment.py", line 719, in get_template
return self._load_template(name, self.make_globals(globals))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/jinja2/jinja2/environment.py", line 693, in _load_template
template = self.loader.load(self, name, globals)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/jinja2/jinja2/loaders.py", line 115, in load
source, filename, uptodate = self.get_source(environment, name)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/jinja2/jinja2/loaders.py", line 165, in get_source
f = open_if_exists(filename)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/jinja2/jinja2/utils.py", line 224, in open_if_exists
return open(filename, mode)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 592, in __init__
raise IOError(errno.EACCES, 'file not accessible', filename)
IOError: [Errno 13] file not accessible: 'templates/test.html'
INFO 2012-02-14 21:54:05,006 dev_appserver.py:2884] "GET /test HTTP/1.1" 500 -
The app is just:
handlers.py:
import webapp2
from webapp2_extras import jinja2
class BaseHandler(webapp2.RequestHandler):
#webapp2.cached_property
def jinja2(self):
# Returns a Jinja2 renderer cached in the app registry.
return jinja2.get_jinja2(app=self.app)
def render_response(self, _template, **context):
# Renders a template and writes the result to the response.
rv = self.jinja2.render_template(_template, **context)
self.response.write(rv)
class MyHandler(BaseHandler):
def get(self):
context = {'message': 'Hello, world!'}
self.render_response('test.html', **context)
webapp2_config = {}
webapp2_config['webapp2_extras.sessions'] = {
'secret_key': 'ef23fsdawe444',
}
application = webapp2.WSGIApplication([
webapp2.Route(r'/test', handler=MyHandler, name='test'),
], debug=True, config=webapp2_config)
app.yaml:
application: sampleapp
version: 0-01
api_version: 1
runtime: python27
threadsafe: false
builtins:
- remote_api: on
handlers:
- url: .*
script: handlers.application
libraries:
- name: jinja2
version: 2.6
- name: webapp2
version: 2.3
There's also a templates directory with test.html in it.
Now when I run the app from a different directory, it works fine.
This google python group post gave me a hint to try a different directory, but I have no idea what's wrong with the original, which ran versions of the code without jinja2 from webapp2_extras fine.
Version info:
OS X 10.6.8,
GoogleAppEngineLauncher: 1.6.2,
Python: 2.7.2
I reinstalled everything, and set my PYTHONPATH to "" in my .bash_profile, but that didn't change anything.
Note: I did strip out a few of the non public directory names from the debug output, but they didn't have spaces or anything.
A few others had a similar error, but their fixes were for older versions. There seems to be something about os.path
root folder and any folder you set in app.yaml as static dir won't work with jinja2 FileSystemLoader
While you're deploying, the value of upload_dir will go into CDN instead of GAE instance, though you're currently in local development server, App Engine SDK prevent you load files from where you couldn't find on production.
I was getting this error of yours, but without using the jinja2 from webapp2_extras (I was creating a jinja_enviroment myself, like
jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))
). I solved it by ignoring that os.path.dirname(__file__) that is in the docs and just putting
jinja_environment = jinja2.Environment(loader=jinja2.FileSystemLoader('templates'))
So I thought I could help, but tried to solve your problem and nothing came. But when you said
A few others had a similar error, but their fixes were for older
versions. There seems to be something about os.path
what did you mean? Are you using os.path in some part of the code? Because os.path is problematic and webapp2_extras.jinja2 don't use it, it just creates the environment with 'templates' handwritten as the template directory. Check the source.
So, maybe there's a hint somewhere in this comment. Good luck.