Helloworld error on Leopard

9 views
Skip to first unread message

Aitor García

unread,
Apr 8, 2008, 10:15:08 AM4/8/08
to Google App Engine
Hello everybody,

I'm really a newbie on python, so maybe the question and the problem
is so stupid that the answer is obvious to everybody but me... but I
can't get the helloworld example running and can't find nothing
related with this in the mail list archive. I've a brand new Leopard
installation (Python2.5 AFAIK) and after creating app.yaml and
helloword.py and running it I'm getting this error:

http://pastie.caboo.se/177197

And I can't figure out the CouldNotFindModuleError reason since
everything (from file names to paths) looks ok to me. Some indications
on possibles causes will be great.

Thanks in advance.

Paul Kretek

unread,
Apr 8, 2008, 12:02:47 PM4/8/08
to Google App Engine
Hi,

I don't think it's a problem with Leopard, since it's what i use too.
Check your yaml file for errors. You can also verify your installation
by executing:

dev_appserver.py /usr/local/google_appengine/demos/guestbook


Paul

Aadi Deshpande

unread,
Apr 8, 2008, 1:44:46 PM4/8/08
to Google App Engine
I have the same error on my leopard box. I believe the error may be
in the handler section but I'm not sure how many different ways I can
try it before I pull my hair out.

Is the format for the handler section like so:


handlers:{nl}
-{sp}url:{sp}.*{nl}
{sp}{sp}script:{sp}main.py

where {nl} is newline and {sp} is space, which becomes :

handlers:
- url: .*
script: main.py


this is what i have, but it doesn't seem to want to work.

Philip J Beyer

unread,
Apr 8, 2008, 11:27:11 PM4/8/08
to Google App Engine

i just had the same problem. in case you haven't already figured it
out, here's what i did:

i'm using TextMate, so i had some automatically inserted TABs. i had
to make sure that my syntax was what cilquirm posted above AND the
last line was completely blank... NO characters at all including
spaces or TABs

good luck!

Phil

nathanziarek

unread,
May 4, 2008, 8:39:25 PM5/4/08
to Google App Engine
I am still having the same problem. The guest book functions fine, so
it can't be my install. This is just the hello world app, and I've
typed, retyped, copy and pasted and checked every space, etc I could
find. No dice.

Here what my server output looks like (if that helps):

<type 'exceptions.SyntaxError'> Python 2.5.1: /System/Library/
Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/
MacOS/Python
Mon May 5 00:37:12 2008
A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.

/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in
_HandleRequest(self=<google.appengine.tools.dev_appserver.DevAppServerRequestHandler
instance at 0x12159b8>)
2245 infile,
2246 outfile,
2247 base_env_dict=env_dict)
2248 finally:
2249
self.module_manager.UpdateModuleFileModificationTimes()
base_env_dict undefined, env_dict = {'REMOTE_ADDR': '127.0.0.1',
'REQUEST_METHOD': 'GET', 'SERVER_NAME': 'localhost', 'SERVER_PORT':
'8080', 'SERVER_PROTOCOL': 'HTTP/1.0', 'SERVER_SOFTWARE': 'Development/
1.0'}
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in
Dispatch(self=<google.appengine.tools.dev_appserver.MatcherDispatcher
object at 0x1213fd0>, relative_url='/', path=None,
headers=<mimetools.Message instance at 0x12155f8>,
infile=<cStringIO.StringI object at 0x52aec0>,
outfile=<cStringIO.StringO object at 0x1213260>,
base_env_dict={'REMOTE_ADDR': '127.0.0.1', 'REQUEST_METHOD': 'GET',
'SERVER_NAME': 'localhost', 'SERVER_PORT': '8080', 'SERVER_PROTOCOL':
'HTTP/1.0', 'SERVER_SOFTWARE': 'Development/1.0'})
332 infile,
333 outfile,
334 base_env_dict=base_env_dict)
335
336 return
base_env_dict = {'REMOTE_ADDR': '127.0.0.1', 'REQUEST_METHOD': 'GET',
'SERVER_NAME': 'localhost', 'SERVER_PORT': '8080', 'SERVER_PROTOCOL':
'HTTP/1.0', 'SERVER_SOFTWARE': 'Development/1.0'}
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in Dispatch(self=<google.appengine.tools.dev_appserver.CGIDispatcher
object at 0x1213db0>, relative_url='/', path='helloworld.py',
headers=<mimetools.Message instance at 0x12155f8>,
infile=<cStringIO.StringI object at 0x52aec0>,
outfile=<cStringIO.StringO object at 0x1213260>,
base_env_dict={'REMOTE_ADDR': '127.0.0.1', 'REQUEST_METHOD': 'GET',
'SERVER_NAME': 'localhost', 'SERVER_PORT': '8080', 'SERVER_PROTOCOL':
'HTTP/1.0', 'SERVER_SOFTWARE': 'Development/1.0'})
1741 infile,
1742 outfile,
1743 self._module_dict)
1744 handler.AddDebuggingConsole(relative_url, env, outfile)
1745 finally:
self = <google.appengine.tools.dev_appserver.CGIDispatcher object at
0x1213db0>, self._module_dict = {'codecs': <module 'codecs' from '/
System/Library/Framework...framework/Versions/2.5/lib/python2.5/
codecs.pyc'>, 'encodings': <module 'encodings' from '/System/Library/
Framew...rsions/2.5/lib/python2.5/encodings/__init__.pyc'>,
'encodings.aliases': <module 'encodings.aliases' from '/System/
Librar...ersions/2.5/lib/python2.5/encodings/aliases.pyc'>,
'encodings.ascii': <module 'encodings.ascii' from '/System/Library/.../
Versions/2.5/lib/python2.5/encodings/ascii.pyc'>, 'encodings.utf_8':
<module 'encodings.utf_8' from '/System/Library/.../Versions/2.5/lib/
python2.5/encodings/utf_8.pyc'>, 'google': <module 'google' from '/usr/
local/google_appengine/google/__init__.pyc'>, 'google.appengine':
<module 'google.appengine' from '/usr/local/google_appengine/google/
appengine/__init__.pyc'>, 'google.appengine.api': <module
'google.appengine.api' from '/usr/local/google_appengine/google/
appengine/api/__init__.pyc'>, 'google.appengine.api.api_base_pb':
<module 'google.appengine.api.api_base_pb' from ..._appengine/google/
appengine/api/api_base_pb.pyc'>,
'google.appengine.api.apiproxy_stub_map': <module
'google.appengine.api.apiproxy_stub_map'...gine/google/appengine/api/
apiproxy_stub_map.pyc'>, ...}
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in ExecuteCGI(root_path='/Users/nathanziarek/Source/helloworld',
handler_path='helloworld.py', cgi_path='/Users/nathanziarek/Source/
helloworld/helloworld.py', env={'AUTH_DOMAIN': 'gmail.com',
'CONTENT_LENGTH': '', 'CONTENT_TYPE': 'application/x-www-form-
urlencoded', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/
xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/
plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_ENCODING': 'gzip,
deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-us', 'HTTP_CACHE_CONTROL': 'max-
age=0', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST': 'localhost:
8080', ...}, infile=<cStringIO.StringI object at 0x52aec0>,
outfile=<cStringIO.StringO object at 0x1213260>,
module_dict={'codecs': <module 'codecs' from '/System/Library/
Framework...framework/Versions/2.5/lib/python2.5/codecs.pyc'>,
'encodings': <module 'encodings' from '/System/Library/Framew...rsions/
2.5/lib/python2.5/encodings/__init__.pyc'>, 'encodings.aliases':
<module 'encodings.aliases' from '/System/Librar...ersions/2.5/lib/
python2.5/encodings/aliases.pyc'>, 'encodings.ascii': <module
'encodings.ascii' from '/System/Library/.../Versions/2.5/lib/python2.5/
encodings/ascii.pyc'>, 'encodings.utf_8': <module 'encodings.utf_8'
from '/System/Library/.../Versions/2.5/lib/python2.5/encodings/
utf_8.pyc'>, 'google': <module 'google' from '/usr/local/
google_appengine/google/__init__.pyc'>, 'google.appengine': <module
'google.appengine' from '/usr/local/google_appengine/google/appengine/
__init__.pyc'>, 'google.appengine.api': <module 'google.appengine.api'
from '/usr/local/google_appengine/google/appengine/api/__init__.pyc'>,
'google.appengine.api.api_base_pb': <module
'google.appengine.api.api_base_pb' from ..._appengine/google/appengine/
api/api_base_pb.pyc'>, 'google.appengine.api.apiproxy_stub_map':
<module 'google.appengine.api.apiproxy_stub_map'...gine/google/
appengine/api/apiproxy_stub_map.pyc'>, ...}, exec_script=<function
ExecuteOrImportScript at 0x6c6970>)
1652 logging.debug('Executing CGI with env:\n%s',
pprint.pformat(env))
1653 try:
1654 reset_modules = exec_script(handler_path, cgi_path, hook)
1655 except SystemExit, e:
1656 logging.debug('CGI exited with status: %s', e)
reset_modules = True, exec_script = <function ExecuteOrImportScript at
0x6c6970>, handler_path = 'helloworld.py', cgi_path = '/Users/
nathanziarek/Source/helloworld/helloworld.py', hook =
<google.appengine.tools.dev_appserver.HardenedModulesHook object at
0x6dfb90>
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in ExecuteOrImportScript(handler_path='helloworld.py', cgi_path='/
Users/nathanziarek/Source/helloworld/helloworld.py',
import_hook=<google.appengine.tools.dev_appserver.HardenedModulesHook
object at 0x6dfb90>)
1548 """
1549 module_fullname, script_module, module_code =
LoadTargetModule(
1550 handler_path, cgi_path, import_hook)
1551 script_module.__name__ = '__main__'
1552 sys.modules['__main__'] = script_module
handler_path = 'helloworld.py', cgi_path = '/Users/nathanziarek/Source/
helloworld/helloworld.py', import_hook =
<google.appengine.tools.dev_appserver.HardenedModulesHook object at
0x6dfb90>
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in LoadTargetModule(handler_path='helloworld.py', cgi_path='/Users/
nathanziarek/Source/helloworld/helloworld.py',
import_hook=<google.appengine.tools.dev_appserver.HardenedModulesHook
object at 0x6dfb90>, module_dict={'BaseHTTPServer': <module
'BaseHTTPServer' from '/System/Library/F...k/Versions/2.5/lib/
python2.5/BaseHTTPServer.pyc'>, 'Carbon': <module 'Carbon' from '/
System/Library/Framework.../2.5/lib/python2.5/plat-mac/Carbon/
__init__.pyc'>, 'Carbon.File': <module 'Carbon.File' from '/System/
Library/Fram...ions/2.5/lib/python2.5/plat-mac/Carbon/File.pyc'>,
'Carbon.Files': <module 'Carbon.Files' from '/System/Library/Fra...ons/
2.5/lib/python2.5/plat-mac/Carbon/Files.pyc'>, 'Carbon.Res': <module
'Carbon.Res' from '/System/Library/Frame...sions/2.5/lib/python2.5/
plat-mac/Carbon/Res.pyc'>, 'Carbon._File': None, 'Carbon._Res': None,
'Carbon.warnings': None, 'Cookie': <module 'Cookie' from '/System/
Library/Framework...framework/Versions/2.5/lib/python2.5/Cookie.pyc'>,
'MacOS': <module 'MacOS' from '/System/Library/Frameworks...Versions/
2.5/lib/python2.5/lib-dynload/MacOS.so'>, ...})
1506 source_file = open(cgi_path)
1507 try:
1508 module_code = compile(source_file.read(), cgi_path,
'exec')
1509 script_module.__file__ = cgi_path
1510 finally:
module_code = None, builtin compile = <built-in function compile>,
source_file = <closed file '/Users/nathanziarek/Source/helloworld/
helloworld.py', mode 'r' at 0x7e3a80>, source_file.read = <built-in
method read of FakeFile object at 0x7e3a80>, cgi_path = '/Users/
nathanziarek/Source/helloworld/helloworld.py'
<type 'exceptions.SyntaxError'>: invalid syntax (helloworld.py, line 1)

nathanziarek

unread,
May 4, 2008, 8:48:20 PM5/4/08
to Google App Engine
I've kept reading and it seems as if the "real" error is listed at the
bottom of the report. In that case, it is invalid syntax in helloworld
line 1.

My helloworld.py file is three lines as looks like this:

print{sp}'Content-Type:{sp}text/plain'{nl}
print{sp}''{nl}
print{sp}'Hello cruel world!'

which reads like...

print 'Content-Type: text/plain'
print ''
print 'Hello cruel world!'

I am a Python newb, and may find Python above my PHP knowledge
level...especially if I can get a three line "helloworld" file to
work!

Thanks for any help you can provide!

nate

Devraj Mukherjee

unread,
May 4, 2008, 10:12:35 PM5/4/08
to google-a...@googlegroups.com
What does your app.yaml look like?

--
"I never look back darling, it distracts from the now", Edna Mode (The
Incredibles)

nathanziarek

unread,
May 5, 2008, 7:27:22 AM5/5/08
to Google App Engine
My app.yaml file is 8 lines long and looks like this:

application:{sp}helloworld{nl}
version:{sp}1{nl}
runtime:{sp}python{nl}
api_version:{sp}1{nl}
{nl}
handlers:{nl}
-{sp}url:{sp}.*{nl}
{sp}{sp}script:{sp}helloworld.py

...which looks like...

application: helloworld
version: 1
runtime: python
api_version: 1

handlers:
- url: .*
script: helloworld.py

I've also tried a / before the dot in the URL template (per Google
actual instructions), to no avail. I removed it based on the feedback
in this thread.

Thanks!

Daniel O'Brien

unread,
May 5, 2008, 1:30:23 PM5/5/08
to Google App Engine
You mentioned checking every space, but if you haven't already take a
look at your newline characters. Specifically, make sure that all of
the lines in your source files end in \n, rather than \r\n.

Based on the error log posted, it looks as if Python's native compile
method is throwing the error, and the notable caveat of compile is
that it only accepts \n (LF) for line endings. If you're editing your
files on Windows, though, or an editor configured to use Windows line
endings, you may end up with \r\n (CRLF) instead, causing the errors
you're seeing.

Daniel

mark

unread,
May 6, 2008, 12:23:24 AM5/6/08
to Google App Engine
just to back up the parent suggestion of checking for CRLF vs. LF:
in macosx:

$ head -n 1 [your-python-script] | hexdump -C

if the last two hex values of hexdump output is '0a 0d' ...then you do
have CRLF.

hope that helps.

Bob Klosinski

unread,
May 6, 2008, 4:23:05 PM5/6/08
to Google App Engine
I think the problem may be a lot simpler than all of this jazz. Check
the spelling of the helloworld.py file.

Bob Klosinski

unread,
May 6, 2008, 4:25:52 PM5/6/08
to Google App Engine
By that I mean make sure the filename is helloworld.py not
helloword.py or something else.

Abdul Qabiz

unread,
Jun 18, 2008, 5:01:48 AM6/18/08
to Google App Engine
It's indeed because of line-ending. To fix this, you can open in
TextMate and save as with LF (line ending).

-abdul
Reply all
Reply to author
Forward
0 new messages