help installing on GAE 1.1.9

22 views
Skip to first unread message

Bayle

unread,
Feb 16, 2009, 8:04:39 AM2/16/09
to pylons-discuss
hi, i'm trying to install pylons on google app engine 1.1.9.

I followed the directions on
http://wiki.pylonshq.com/display/pylonscookbook/Creating+a+Pylons+application+for+Google+App+Engine

However, when I attempt to access http://localhost:8080/, I get the
error trace appended below.

In case there is any uncertainty in what I did, I make a shell script,
source code appended below after the error trace. The shell script was
invoked like this:


newpylonsgae testsite /usr/local/google_appengine/

thanks,
bayle


---------------------------------

<type 'exceptions.AttributeError'> Python 2.5.2: /usr/bin/python
Mon Feb 16 12:59:23 2009

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 0x11eb5f0>)
2709 infile,
2710 outfile,
2711 base_env_dict=env_dict)
2712 finally:
2713 self.module_manager.UpdateModuleFileModificationTimes
()
base_env_dict undefined, env_dict = {'APPLICATION_ID': 'testsite',
'CURRENT_VERSION_ID': '1.1', '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 0x1090b90>, relative_url='/', path=None, headers=<mimetools.Message
instance at 0x11eb680>, infile=<cStringIO.StringI object at
0x11ee1e0>, outfile=<cStringIO.StringO object at 0x114e378>,
base_env_dict={'APPLICATION_ID': 'testsite', 'CURRENT_VERSION_ID':
'1.1', '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'})
378 infile,
379 outfile,
380
base_env_dict=base_env_dict)
381
382 if forward:
base_env_dict = {'APPLICATION_ID': 'testsite', 'CURRENT_VERSION_ID':
'1.1', '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 0x1149850>, relative_url='/', path='paste-deploy.py',
headers=<mimetools.Message instance at 0x11eb680>,
infile=<cStringIO.StringI object at 0x11ee1e0>,
outfile=<cStringIO.StringO object at 0x114e378>, base_env_dict=
{'APPLICATION_ID': 'testsite', 'CURRENT_VERSION_ID': '1.1',
'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'})
1996 infile,
1997 outfile,
1998 self._module_dict)
1999 handler.AddDebuggingConsole(relative_url, env, outfile)
2000 finally:
self = <google.appengine.tools.dev_appserver.CGIDispatcher object at
0x1149850>, self._module_dict = {'__main__': <module 'paste-deploy'
from '/home/bshanks/prog/testsite/paste-deploy.py'>, 'codecs': <module
'codecs' from '/usr/lib/python2.5/codecs.pyc'>, 'encodings': <module
'encodings' from '/usr/lib/python2.5/encodings/__init__.pyc'>,
'encodings.aliases': <module 'encodings.aliases' from '/usr/lib/
python2.5/encodings/aliases.pyc'>, 'encodings.ascii': <module
'encodings.ascii' from '/usr/lib/python2.5/encodings/ascii.pyc'>,
'encodings.codecs': None, 'encodings.encodings': None,
'encodings.types': None, 'encodings.utf_8': <module 'encodings.utf_8'
from '/usr/lib/python2.5/encodings/utf_8.pyc'>, 'google': <module
'google' from '/usr/local/google_appengine/google/__init__.pyc'>, ...}
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in ExecuteCGI(root_path='/home/bshanks/prog/testsite',
handler_path='paste-deploy.py', cgi_path='/home/bshanks/prog/testsite/
paste-deploy.py', env={'APPLICATION_ID': 'testsite', 'AUTH_DOMAIN':
'gmail.com', 'CONTENT_LENGTH': '', 'CONTENT_TYPE': 'application/x-www-
form-urlencoded', 'CURRENT_VERSION_ID': '1.1', 'GATEWAY_INTERFACE':
'CGI/1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET':
'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_LANGUAGE': 'en-
us,en;q=0.5', 'HTTP_CACHE_CONTROL': 'max-age=0', ...},
infile=<cStringIO.StringI object at 0x11ee1e0>,
outfile=<cStringIO.StringO object at 0x114e378>, module_dict=
{'__main__': <module 'paste-deploy' from '/home/bshanks/prog/testsite/
paste-deploy.py'>, 'codecs': <module 'codecs' from '/usr/lib/python2.5/
codecs.pyc'>, 'encodings': <module 'encodings' from '/usr/lib/
python2.5/encodings/__init__.pyc'>, 'encodings.aliases': <module
'encodings.aliases' from '/usr/lib/python2.5/encodings/aliases.pyc'>,
'encodings.ascii': <module 'encodings.ascii' from '/usr/lib/python2.5/
encodings/ascii.pyc'>, 'encodings.codecs': None,
'encodings.encodings': None, 'encodings.types': None,
'encodings.utf_8': <module 'encodings.utf_8' from '/usr/lib/python2.5/
encodings/utf_8.pyc'>, 'google': <module 'google' from '/usr/local/
google_appengine/google/__init__.pyc'>, ...}, exec_script=<function
ExecuteOrImportScript at 0x108ec80>)
1914 logging.debug('Executing CGI with env:\n%s', pprint.pformat
(env))
1915 try:
1916 reset_modules = exec_script(handler_path, cgi_path, hook)
1917 except SystemExit, e:
1918 logging.debug('CGI exited with status: %s', e)
reset_modules = True, exec_script = <function ExecuteOrImportScript at
0x108ec80>, handler_path = 'paste-deploy.py', cgi_path = '/home/
bshanks/prog/testsite/paste-deploy.py', hook =
<google.appengine.tools.dev_appserver.HardenedModulesHook object at
0x1090cd0>
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in ExecuteOrImportScript(handler_path='paste-deploy.py', cgi_path='/
home/bshanks/prog/testsite/paste-deploy.py',
import_hook=<google.appengine.tools.dev_appserver.HardenedModulesHook
object at 0x1090cd0>)
1810 try:
1811 if module_code:
1812 exec module_code in script_module.__dict__
1813 else:
1814 script_module.main()
module_code = <code object <module> at 0x11f10a8, file "/home/bshanks/
prog/testsite/paste-deploy.py", line 3>, script_module = <module
'paste-deploy' from '/home/bshanks/prog/testsite/paste-deploy.py'>,
script_module.__dict__ = {'CONF_FILE': 'development.ini',
'__builtins__': {'ArithmeticError': <type
'exceptions.ArithmeticError'>, 'AssertionError': <type
'exceptions.AssertionError'>, 'AttributeError': <type
'exceptions.AttributeError'>, 'BaseException': <type
'exceptions.BaseException'>, 'DeprecationWarning': <type
'exceptions.DeprecationWarning'>, 'EOFError': <type
'exceptions.EOFError'>, 'Ellipsis': Ellipsis, 'EnvironmentError':
<type 'exceptions.EnvironmentError'>, 'Exception': <type
'exceptions.Exception'>, 'False': False, ...}, '__doc__': None,
'__file__': '/home/bshanks/prog/testsite/paste-deploy.py',
'__loader__':
<google.appengine.tools.dev_appserver.HardenedModulesHook object at
0x1090cd0>, '__name__': 'paste-deploy', 'os': <module 'os' from '/usr/
lib/python2.5/os.pyc'>, 'sys': <module 'sys' (built-in)>}
/home/bshanks/prog/testsite/paste-deploy.py in ()
14 "$PYTHONPATH is set. This may cause import problems; it
is best to unset PYTHONPATH before starting the appserver")
15
16 import site
17 site = reload(site)
18 import wsgiref.handlers
site undefined
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in decorate
(self=<google.appengine.tools.dev_appserver.HardenedModulesHook object
at 0x1090cd0>, *args=('site',), **kwargs={})
980 self._indent_level += 1
981 try:
982 return func(self, *args, **kwargs)
983 finally:
984 self._indent_level -= 1
func = <function load_module at 0x108e758>, self =
<google.appengine.tools.dev_appserver.HardenedModulesHook object at
0x1090cd0>, args = ('site',), kwargs = {}
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in load_module
(self=<google.appengine.tools.dev_appserver.HardenedModulesHook object
at 0x1090cd0>, fullname='site')
1570 search_path = parent_module.__path__
1571
1572 return self.FindAndLoadModule(submodule, fullname,
search_path)
1573
1574 @Trace
self = <google.appengine.tools.dev_appserver.HardenedModulesHook
object at 0x1090cd0>, self.FindAndLoadModule = <bound method
HardenedModulesHook.decorate of <g...pserver.HardenedModulesHook
object at 0x1090cd0>>, submodule = 'site', fullname = 'site',
search_path = None
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in decorate
(self=<google.appengine.tools.dev_appserver.HardenedModulesHook object
at 0x1090cd0>, *args=('site', 'site', None), **kwargs={})
980 self._indent_level += 1
981 try:
982 return func(self, *args, **kwargs)
983 finally:
984 self._indent_level -= 1
func = <function FindAndLoadModule at 0x108e398>, self =
<google.appengine.tools.dev_appserver.HardenedModulesHook object at
0x1090cd0>, args = ('site', 'site', None), kwargs = {}
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in FindAndLoadModule
(self=<google.appengine.tools.dev_appserver.HardenedModulesHook object
at 0x1090cd0>, submodule='site', submodule_fullname='site',
search_path=None)
1478 source_file,
1479 pathname,
1480 description)
1481
1482 module.__loader__ = self
description = (None, None, None)
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in decorate
(self=<google.appengine.tools.dev_appserver.HardenedModulesHook object
at 0x1090cd0>, *args=('site', <zipimporter object "/usr/lib/python2.5/
site-packages/setuptools-0.6c9-py2.5.egg">, None, (None, None, None)),
**kwargs={})
980 self._indent_level += 1
981 try:
982 return func(self, *args, **kwargs)
983 finally:
984 self._indent_level -= 1
func = <function LoadModuleRestricted at 0x108e2a8>, self =
<google.appengine.tools.dev_appserver.HardenedModulesHook object at
0x1090cd0>, args = ('site', <zipimporter object "/usr/lib/python2.5/
site-packages/setuptools-0.6c9-py2.5.egg">, None, (None, None, None)),
kwargs = {}
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in LoadModuleRestricted
(self=<google.appengine.tools.dev_appserver.HardenedModulesHook object
at 0x1090cd0>, submodule_fullname='site', source_file=<zipimporter
object "/usr/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg">,
pathname=None, description=(None, None, None))
1421 """
1422 if description == (None, None, None):
1423 return source_file.load_module(submodule_fullname)
1424
1425 try:
source_file = <zipimporter object "/usr/lib/python2.5/site-packages/
setuptools-0.6c9-py2.5.egg">, source_file.load_module = <built-in
method load_module of zipimport.zipimporter object at 0x11f2128>,
submodule_fullname = 'site'
/usr/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/site.py
in ()
71 def makepath(*paths):
72 dir = os.path.abspath(os.path.join(*paths))
73 return dir, os.path.normcase(dir)
74
75 def abs__file__():
builtin dir = <built-in function dir>, os undefined
/usr/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/site.py
in __boot()
24 (resp. /usr/local/lib/site-python), Debian addons install into
25 /usr/lib/python<version>/site-packages.
26
27 A path configuration file is a file whose name has the form
28 <package>.pth; its contents are additional directories (one per
line)
A undefined, path undefined, configuration undefined, builtin file =
<type 'file'>, a undefined, whose undefined, name undefined, has
undefined, the undefined, form undefined

<type 'exceptions.AttributeError'>: 'module' object has no attribute
'find_module'
args = ("'module' object has no attribute 'find_module'",)
message = "'module' object has no attribute 'find_module'"



--------------------------

#!/bin/sh
# newpylonsgae shell script

name=$1; shift
#appengine_monkey_path=$1; shift
google_appengine_path=$1; shift

# google_appengine_path=/usr/local/google_appengine
# appengine_monkey_path=/home/bshanks/prog/appengine-monkey/

svn checkout http://appengine-monkey.googlecode.com/svn/trunk
appengine-monkey
appengine_monkey_path=.

python $appengine_monkey_path/appengine-boot.py --paste-deploy $name
cd $name
source bin/activate
easy_install -U setuptools
bin/easy_install Pylons
rm lib/python2.5/site-packages/simplejson-*-py2.5-*.egg/simplejson/
_speedups.py
cd src/
../bin/paster create -t pylons $name
# choose template engine; choose no sqlalchemy
cd $name
python setup.py develop
../../bin/python -m pth_relpath_fixup
echo "[app:main]\nuse = config:src/taghog/development.ini" > ../../
development.ini
perl -p -e 's/\Qbeaker.session.secret = somesecret\Q/
beaker.session.secret = somesecret\nbeaker.session.type = google
\nbeaker.session.table_name = Session/' -i development.ini
perl -p -e 's/module_directory/#module_directory/' -i $name/config/
environment.py
deactivate
cd ../../../
python $google_appengine_path/dev_appserver.py $name

Bayle

unread,
Feb 16, 2009, 8:13:49 AM2/16/09
to pylons-discuss
umm, sorry, i sent the wrong version of the shell script in the
previous message. it should have had the line
"appengine_monkey_path=appengine-monkey", rather than
"appengine_monkey_path=.". here is the revised version:




#!/bin/sh
# newpylonsgae shell script

name=$1; shift
#appengine_monkey_path=$1; shift
google_appengine_path=$1; shift

# google_appengine_path=/usr/local/google_appengine
# appengine_monkey_path=/home/bshanks/prog/appengine-monkey/

svn checkout http://appengine-monkey.googlecode.com/svn/trunk
appengine-monkey
appengine_monkey_path=appengine-monkey

Bayle

unread,
Feb 16, 2009, 8:39:43 AM2/16/09
to pylons-discuss
I got it working with GAE 1.1.2, but not with GAE 1.1.3, much like
matdrapeau at this link: http://code.google.com/p/appengine-monkey/wiki/Pylons

So, I guess the same bug is preventing both me and matdrapeau from
getting later versions working. Any ideas what it might be? thanks

Also, there were another 2 mistakes in my script, here is a newly
revised version:

#!/bin/sh
# newpylonsgae shell script

name=$1; shift
#appengine_monkey_path=$1; shift
google_appengine_path=$1; shift

# google_appengine_path=/usr/local/google_appengine
# appengine_monkey_path=/home/bshanks/prog/appengine-monkey/

svn checkout http://appengine-monkey.googlecode.com/svn/trunk
appengine-monkey
appengine_monkey_path=appengine-monkey

python $appengine_monkey_path/appengine-boot.py --paste-deploy $name
cd $name
source bin/activate
easy_install -U setuptools
bin/easy_install Pylons
rm lib/python2.5/site-packages/simplejson-*-py2.5-*.egg/simplejson/
_speedups.py
cd src/
../bin/paster create -t pylons $name
# choose template engine; choose no sqlalchemy
cd $name
python setup.py develop
../../bin/python -m pth_relpath_fixup
echo -e "[app:main]\nuse = config:src/$name/development.ini" > ../../

Mike Orr

unread,
Feb 16, 2009, 5:30:01 PM2/16/09
to pylons-...@googlegroups.com
App Engine is a moving target because it doesn't fully support
Setuptools. My older application works using the following versions:

appengine_monkey-0.1dev_r40-py2.5.egg
Beaker-1.0.3-py2.5.egg
decorator-2.2.0-py2.5.egg
easy-install.pth
FormEncode-1.0.1-py2.5.egg
Mako-0.2.2-py2.5.egg
nose-0.10.4-py2.5.egg
Paste-1.7.2-py2.5.egg
PasteDeploy-1.3.2-py2.5.egg
PasteScript-1.7.2-py2.5.egg
Pygments-0.9-py2.5.egg
Pylons-0.9.7rc2-py2.5.egg
RecipeDepot.egg-link
Routes-1.10.1-py2.5.egg
setuptools-0.6c9-py2.5.egg
setuptools.pth
simplejson-2.0.4-py2.5-linux-i686.egg
Tempita-0.2-py2.5.egg
WebError-0.9.1-py2.5.egg
WebHelpers-0.6.4dev_20081116-py2.5.egg
WebOb-0.9.4-py2.5.egg
wsgiref-0.1.2-py2.5.egg

I built it using an App Engine somewhere between 1.1.3 and 1.1.7, but
it works on 1.1.9.

Google modified the standard library in 1.1.9 to make appengine-monkey
unnecessary, but they didn't modify it enough. See
http://code.google.com/p/googleappengine/issues/detail?id=60

This is similar to your problem in terms of an AttributeError in the
standard library, but my app is working in the same SDK versions that
yours is not, so there may be something different in the
appengine-monkey version or paste-deploy.py configuration.

I'm going to try a new application with the current Pylons and
libraries this week, so I may know more in a couple days.

--
Mike Orr <slugg...@gmail.com>

Bayle

unread,
Feb 16, 2009, 7:22:26 PM2/16/09
to pylons-discuss
If it helps, I noticed that the error trace I get with 1.1.9 mentions
zipimporter trying to do something with /usr/lib/python2.5/site-
packages/setuptools-0.6c9-py2.5.egg, and I noticed that during the
pth_relpath_fixup there was the following error:

WARNING: /usr/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg
is installed as a zip file
Libraries must be installed with easy_install --always-unzip

So, as root, I installed the unpacked version of setuptools-0.6c9-
py2.5.egg to /usr/lib/python2.5/site-packages/, by doing

# cd /usr/lib/python2.5/site-packages
# mv setuptools-0.6c9-py2.5.egg setuptools-0.6c9-py2.5.egg-old
# cp -r ~bshanks/prog/testsite/lib/python2.5/site-packages/
setuptools-0.6c9-py2.5.egg .

Of course, mucking with things as root shouldn't be required, but
anyhow:

Now when I try to run it, I get a different error, about the "site"
module not being found (appended below).

thanks,
bayle

---------------

<type 'exceptions.ImportError'> Python 2.5.2: /usr/bin/python
Tue Feb 17 00:20:34 2009

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 0x1008a28>)
2401 infile,
2402 outfile,
2403 base_env_dict=env_dict)
2404 finally:
2405 self.module_manager.UpdateModuleFileModificationTimes
()
base_env_dict undefined, env_dict = {'APPLICATION_ID': 'testsite',
'CURRENT_VERSION_ID': '1.1', '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 0xf51810>, relative_url='/', path=None, headers=<mimetools.Message
instance at 0x1008ab8>, infile=<cStringIO.StringI object at
0x100f1b0>, outfile=<cStringIO.StringO object at 0xf4dc70>,
base_env_dict={'APPLICATION_ID': 'testsite', 'CURRENT_VERSION_ID':
'1.1', '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'})
346 infile,
347 outfile,
348 base_env_dict=base_env_dict)
349
350 return
base_env_dict = {'APPLICATION_ID': 'testsite', 'CURRENT_VERSION_ID':
'1.1', '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 0xf51890>, relative_url='/', path='paste-deploy.py',
headers=<mimetools.Message instance at 0x1008ab8>,
infile=<cStringIO.StringI object at 0x100f1b0>,
outfile=<cStringIO.StringO object at 0xf4dc70>, base_env_dict=
{'APPLICATION_ID': 'testsite', 'CURRENT_VERSION_ID': '1.1',
'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'})
1836 infile,
1837 outfile,
1838 self._module_dict)
1839 handler.AddDebuggingConsole(relative_url, env, outfile)
1840 finally:
self = <google.appengine.tools.dev_appserver.CGIDispatcher object at
0xf51890>, self._module_dict = {'__main__': <module 'paste-deploy'
from '/home/bshanks/prog/testsite/paste-deploy.py'>, 'codecs': <module
'codecs' from '/usr/lib/python2.5/codecs.pyc'>, 'encodings': <module
'encodings' from '/usr/lib/python2.5/encodings/__init__.pyc'>,
'encodings.aliases': <module 'encodings.aliases' from '/usr/lib/
python2.5/encodings/aliases.pyc'>, 'encodings.ascii': <module
'encodings.ascii' from '/usr/lib/python2.5/encodings/ascii.pyc'>,
'encodings.codecs': None, 'encodings.encodings': None,
'encodings.types': None, 'encodings.utf_8': <module 'encodings.utf_8'
from '/usr/lib/python2.5/encodings/utf_8.pyc'>, 'google': <module
'google' from '/usr/local/google_appengine/google/__init__.pyc'>, ...}
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in ExecuteCGI(root_path='/home/bshanks/prog/testsite',
handler_path='paste-deploy.py', cgi_path='/home/bshanks/prog/testsite/
paste-deploy.py', env={'APPLICATION_ID': 'testsite', 'AUTH_DOMAIN':
'gmail.com', 'CONTENT_LENGTH': '', 'CONTENT_TYPE': 'application/x-www-
form-urlencoded', 'CURRENT_VERSION_ID': '1.1', 'GATEWAY_INTERFACE':
'CGI/1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET':
'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING':
'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5', ...},
infile=<cStringIO.StringI object at 0x100f1b0>,
outfile=<cStringIO.StringO object at 0xf4dc70>, module_dict=
{'__main__': <module 'paste-deploy' from '/home/bshanks/prog/testsite/
paste-deploy.py'>, 'codecs': <module 'codecs' from '/usr/lib/python2.5/
codecs.pyc'>, 'encodings': <module 'encodings' from '/usr/lib/
python2.5/encodings/__init__.pyc'>, 'encodings.aliases': <module
'encodings.aliases' from '/usr/lib/python2.5/encodings/aliases.pyc'>,
'encodings.ascii': <module 'encodings.ascii' from '/usr/lib/python2.5/
encodings/ascii.pyc'>, 'encodings.codecs': None,
'encodings.encodings': None, 'encodings.types': None,
'encodings.utf_8': <module 'encodings.utf_8' from '/usr/lib/python2.5/
encodings/utf_8.pyc'>, 'google': <module 'google' from '/usr/local/
google_appengine/google/__init__.pyc'>, ...}, exec_script=<function
ExecuteOrImportScript at 0xea9e60>)
1754 logging.debug('Executing CGI with env:\n%s', pprint.pformat
(env))
1755 try:
1756 reset_modules = exec_script(handler_path, cgi_path, hook)
1757 except SystemExit, e:
1758 logging.debug('CGI exited with status: %s', e)
reset_modules = True, exec_script = <function ExecuteOrImportScript at
0xea9e60>, handler_path = 'paste-deploy.py', cgi_path = '/home/bshanks/
prog/testsite/paste-deploy.py', hook =
<google.appengine.tools.dev_appserver.HardenedModulesHook object at
0xeab6d0>
/usr/local/google_appengine/google/appengine/tools/dev_appserver.py
in ExecuteOrImportScript(handler_path='paste-deploy.py', cgi_path='/
home/bshanks/prog/testsite/paste-deploy.py',
import_hook=<google.appengine.tools.dev_appserver.HardenedModulesHook
object at 0xeab6d0>)
1650 try:
1651 if module_code:
1652 exec module_code in script_module.__dict__
1653 else:
1654 script_module.main()
module_code = <code object <module> at 0x1012120, file "/home/bshanks/
prog/testsite/paste-deploy.py", line 3>, script_module = <module
'paste-deploy' from '/home/bshanks/prog/testsite/paste-deploy.py'>,
script_module.__dict__ = {'CONF_FILE': 'development.ini',
'__builtins__': {'ArithmeticError': <type
'exceptions.ArithmeticError'>, 'AssertionError': <type
'exceptions.AssertionError'>, 'AttributeError': <type
'exceptions.AttributeError'>, 'BaseException': <type
'exceptions.BaseException'>, 'DeprecationWarning': <type
'exceptions.DeprecationWarning'>, 'EOFError': <type
'exceptions.EOFError'>, 'Ellipsis': Ellipsis, 'EnvironmentError':
<type 'exceptions.EnvironmentError'>, 'Exception': <type
'exceptions.Exception'>, 'False': False, ...}, '__doc__': None,
'__file__': '/home/bshanks/prog/testsite/paste-deploy.py',
'__loader__':
<google.appengine.tools.dev_appserver.HardenedModulesHook object at
0xeab6d0>, '__name__': 'paste-deploy', 'os': <module 'os' from '/usr/
lib/python2.5/os.pyc'>, 'sys': <module 'sys' (built-in)>}
/home/bshanks/prog/testsite/paste-deploy.py in ()
14 "$PYTHONPATH is set. This may cause import problems; it
is best to unset PYTHONPATH before starting the appserver")
15
16 import site
17 site = reload(site)
18 import wsgiref.handlers
site undefined

<type 'exceptions.ImportError'>: No module named site
args = ('No module named site',)
message = 'No module named site'

Bayle

unread,
Feb 16, 2009, 7:28:50 PM2/16/09
to pylons-discuss
(my $PYTHONPATH is not set)

Mike Orr

unread,
Feb 16, 2009, 7:43:21 PM2/16/09
to pylons-...@googlegroups.com
On Mon, Feb 16, 2009 at 4:22 PM, Bayle <bayle....@gmail.com> wrote:
>
> If it helps, I noticed that the error trace I get with 1.1.9 mentions
> zipimporter trying to do something with /usr/lib/python2.5/site-
> packages/setuptools-0.6c9-py2.5.egg, and I noticed that during the
> pth_relpath_fixup there was the following error:
>
> WARNING: /usr/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg
> is installed as a zip file
> Libraries must be installed with easy_install --always-unzip
>
> So, as root, I installed the unpacked version of setuptools-0.6c9-
> py2.5.egg to /usr/lib/python2.5/site-packages/, by doing
>
> # cd /usr/lib/python2.5/site-packages
> # mv setuptools-0.6c9-py2.5.egg setuptools-0.6c9-py2.5.egg-old
> # cp -r ~bshanks/prog/testsite/lib/python2.5/site-packages/
> setuptools-0.6c9-py2.5.egg .
>
> Of course, mucking with things as root shouldn't be required,

You should not be using nonstandard libraries installed in /usr/lib,
because they will not be available in the server environment. You'll
have to install Setuptools into the virtualenv. We're not sure at
this point which libraries can be zipped, because "zip safe for App
Engine" is not necessarily the same as "zip safe for Python". So I
would start with all packages unzipped, and then zip them one by one
if you're over the 1000-file limit. You can also delete large
subdirectories that you don't use, such as webhelpers/rails, etc. I'm
planning on making a standard Pylons archive that can be dropped into
a virtualenv without easy_installing everything, if I can get it to
work.

> but
> anyhow:
>
> Now when I try to run it, I get a different error, about the "site"
> module not being found (appended below).

That happens at various times, I'm not sure exactly under what
circumstances. It indicates some discrepency between sys.path and the
standard site.py vs virtualenv's site.py. Sometimes reinstalling the
application ("python setup.py develop") fixes ImportError's.

Appengine-monkey has a new command to create the virtualenv, which I
haven't tried yet so it's not in the wiki instructions, but Ian
recommends it. I'd try starting over with that and seeing if it
helps. And use the --no-site-packages option, whatever it's called.

--
Mike Orr <slugg...@gmail.com>

Bayle

unread,
Feb 16, 2009, 11:31:50 PM2/16/09
to pylons-discuss
Thanks for your help. I tried your suggestions (except for the new
command, which I couldn't find), but it isn't fixed yet. I could
probably benefit from a better understanding on what it is that the
sequence of commands given in the cookbook is trying to do. I don't
really understand whether or how dev_appserver makes use of modules
installed, either in the system or in the virtualenv, and I don't
understand how appengine-monkey works.

Also, I know that SDK 1.1.2 works for me, and not SDK 1.1.3 or
greater, but I know that you have installed on an older SDK and then
upgraded the SDK and it works. But I tried that, and it didn't work
for me. Is it possible that I actually did exactly the same thing that
you did to install, but that it didn't work for me because I am on a
different platform? I am using Debian GNU/Linux x86_64. Is it known if
anyone has successfully gotten SDK >1.1.3 to run on Debian using the
cookbook instructions?

I suspect that the modules installed in the virtualenv are not being
used by the appserver, which is why I get errors suggesting that it is
looking in /usr/lib.

I don't really understand why the virtualenv modules WOULD be used in
the first place, since I deactivate the virtualenv before running
dev_appserver.py. Is dev_appserver.py supposed to be using the modules
in the virtualenv? If so, how do I confirm that it is doing so? If
not, then why would "import site" fail when run on the appserver,
because I can run "python -m site" from the commandline with no
problems?

More details below.


> Sometimes reinstalling the
> application ("python setup.py develop") fixes ImportError's.

Tried it but it didn't work.

> You should not be using nonstandard libraries installed in /usr/lib,
> because they will not be available in the server environment.
> You'll
> have to install Setuptools into the virtualenv.

Is the appserver supposed to be using libraries from /usr/lib at all?
I was under the impression that the sequence of commands I described
(in my script) was supposed to create a virtualenv that would be
populated with all the needed libraries, and that the appserver would
use those.

As for setuptools, it seems that it already is installed in my
virtualenv; there is a directory at

testsite/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/


> Appengine-monkey has a new command to create the virtualenv,
> which I
> haven't tried yet so it's not in the wiki instructions, but Ian
> recommends it. I'd try starting over with that and seeing if it
> helps.

could you tell me where to look for further information about the new
command? here is where i have tried to look so far:

* the "docs" directory in SVN is empty except for a license file
* http://code.google.com/p/appengine-monkey/ just says to take a look
at http://code.google.com/p/appengine-monkey/wiki/Pylons , which looks
like another version of the cookbook page
* running python appengine-monkey/appengine-boot.py --help

> And use the --no-site-packages option, whatever it's called.

Tried it but it didn't work.


thanks,
bayle

Mike Orr

unread,
Feb 17, 2009, 12:46:24 AM2/17/09
to pylons-...@googlegroups.com
On Mon, Feb 16, 2009 at 8:31 PM, Bayle <bayle....@gmail.com> wrote:
>
> Thanks for your help. I tried your suggestions (except for the new
> command, which I couldn't find),

This is what Ian wrote me in December. He hasn't announced it because
it hasn't been widely tested (or maybe he forgot).

"""
I've created a new script as an alternative to appengine-boot,
appengine-homedir (also in appengine-monkey). This sets up a
virtualenv, and then inside the virtualenv it creates an app/
application directory. I think it's a big improvement.

The basic usage is:

$ python2.5 appengine-homedir.py MyApplication
$ cd MyApplication
$ ./bin/pip install SomeLibrary
$ cd app
... edit code in ./myapplication/ ...
$ dev_appserver.py .

I also added some code to sitecustomize.py which will initialize the
google SDK, so you can use the database etc from the code.
"""


> I could
> probably benefit from a better understanding on what it is that the
> sequence of commands given in the cookbook is trying to do. I don't
> really understand whether or how dev_appserver makes use of modules
> installed, either in the system or in the virtualenv, and I don't
> understand how appengine-monkey works.

Look at the source of dev_appserver.py and paste-deploy.py (in your
application). Google adds several directories to sys.path for its
SDK, relative to the location of dev_appserver.py. On the production
server, these paths are built into the runtime environment.

paste-deploy.py essentially does the same thing, adding the
virtualenv's site-packages directory to sys.path. It has to add it as
a site directory (using the site module) so that .pth files in it will
be processed. Note that site and sitecustomize were mentioned in your
error messages. Another problem I've had is that normal Python will
adds zip mentioned in .pth files, while the production server didn't,
although that may have been fixed. For this and other reasons, I've
sometimes had to add egg directories and zipped eggs explicitly to
sys.path in paste-deploy.py even though Python "should have added
them" due on the .pth files.

Another problem you may encounter is that the WebOb in the SDK is too
old for Pylons 0.9.7. I delete it from the SDK; some others modify
sys.path to put the newer one before it, but that may be a problem if
App Engine has already imported it.

The system site-packages is automatically on sys.path if you didn't
use --no-site-packages or whatever the option is called. This may or
may not cause OS versions of Setuptools etc to be imported in the
development server. That could explain the /usr/lib paths appearing
in your tracebacks. The production server does not have your system
site-packages, so it won't be able to import anything from there.

The appengine-monkey module ("import appengine_monkey" in
paste-deploy.py) replaces missing modules and functions in the Python
standard library with stubs. This doesn't provide the
filesystem/network capability which is forbidden in App Engine, but it
does allow packages that merely import these modules to work.
Setuptools is the main package that needs these patches.
imp.find_module() is a different case because Setuptools not only
needs the function to exist, it needs it to work too. It works with
appengine-monkey (at least on my system) but not currently without it,
although the App Engine team has recognized it probably should.

> Also, I know that SDK 1.1.2 works for me, and not SDK 1.1.3 or
> greater, but I know that you have installed on an older SDK and then
> upgraded the SDK and it works. But I tried that, and it didn't work
> for me. Is it possible that I actually did exactly the same thing that
> you did to install, but that it didn't work for me because I am on a
> different platform? I am using Debian GNU/Linux x86_64. Is it known if
> anyone has successfully gotten SDK >1.1.3 to run on Debian using the
> cookbook instructions?

I'm using Kubuntu 8.04, which should be similar. I've also gotten at
least parts of it to work on my MacBook.

> I suspect that the modules installed in the virtualenv are not being
> used by the appserver, which is why I get errors suggesting that it is
> looking in /usr/lib.
>
> I don't really understand why the virtualenv modules WOULD be used in
> the first place, since I deactivate the virtualenv before running
> dev_appserver.py. Is dev_appserver.py supposed to be using the modules
> in the virtualenv? If so, how do I confirm that it is doing so?

You deactivate the virtualenv because it can't run on the production
servers. paste-deploy.py does the equivalent of the activate script;
that's why it modifies sys.path.

The surest way to tell which libraries it's using is to write a CGI
script that prints the current value of sys.path and
repr(pkg_resources). The repr of a module shows which directory it
was loaded from. pkg_resources is the part of setuptools that's used
by paste/pylons. Something like this:

print "Content-type: text-plain"
print
import pprint
import sys
pprint.pprint(sys.path)
try:
import pkg_resources
print repr(pkg_resources)
except ImportError:
print "pkg_resources module not found"

You can probably put this code directly into paste-deploy.py .

> If
> not, then why would "import site" fail when run on the appserver,
> because I can run "python -m site" from the commandline with no
> problems?

Because dev_appserver.py has modified the Python path, and it can be
complicated to figure out how that interacts with the virtualenv and
your system's site-packages.

>> You should not be using nonstandard libraries installed in /usr/lib,
>> because they will not be available in the server environment.
>> You'll
>> have to install Setuptools into the virtualenv.
>
> Is the appserver supposed to be using libraries from /usr/lib at all?

Only the ones that are in the Python standard library.

--
Mike Orr <slugg...@gmail.com>

Bayle

unread,
Feb 17, 2009, 6:08:36 AM2/17/09
to pylons-discuss
Thanks a bunch! I think I found the problem. In paste-deploy.py, the
command "import site" occurs before sys.path is altered. Changing this
fixes the problem. ischenko noticed this previously, but until I
understood what was going on a little better, thanks to your
explanation, I hadn't thought that the "import site" line could have
been the problem. Here's ischenko's issue report:
http://code.google.com/p/appengine-monkey/issues/detail?id=15 .

I guess I'll submit the patch below to Ian B., also.

thanks a bunch,
bayle


Here is a revised shell script which patches paste-deploy.py:

#!/bin/sh
# newpylonsgae shell script
# example usage:
# newpylonsgae testsite /usr/local/google_appengine


name=$1; shift
#appengine_monkey_path=$1; shift
google_appengine_path=$1; shift

# google_appengine_path=/usr/local/google_appengine
# appengine_monkey_path=/home/bshanks/prog/appengine-monkey/

cat << EOF >appengine-monkey-patch
Index: paste-deploy.py
===================================================================
--- paste-deploy.py (revision 48)
+++ paste-deploy.py (working copy)
@@ -13,8 +13,6 @@
print >> sys.stderr, (
"$PYTHONPATH is set. This may cause import problems\; it is
best to unset PYTHONPATH before starting the appserver")

-import site
-site = reload(site)
import wsgiref.handlers

try:
@@ -24,6 +22,9 @@
# XXX Could become more sophisticated
sys.path = [path for path in sys.path if "site-packages" not in
path]

+ import site
+ site = reload(site)
+
# The "src" path is added to ensure to find our main app
(Problems under Windows)
sys.path.insert(0, os.path.join(here, "src", "myapp"))

EOF



svn checkout http://appengine-monkey.googlecode.com/svn/trunk
appengine-monkey
appengine_monkey_path=appengine-monkey

cd $appengine_monkey_path
patch < ../appengine-monkey-patch
cd ..

python $appengine_monkey_path/appengine-boot.py --no-site-packages --
unzip-setuptools --paste-deploy $name
cd $name
source bin/activate
easy_install --always-copy -U setuptools
bin/easy_install --always-copy Pylons
rm lib/python2.5/site-packages/simplejson-*-py2.5-*.egg/simplejson/
_speedups.py
cd src/
../bin/paster create -t pylons $name
# choose template engine; choose no sqlalchemy
cd $name
../../bin/python setup.py develop

Mykola

unread,
Mar 8, 2009, 7:05:29 AM3/8/09
to pylons-discuss
Got absolutely the same error, any ideas how this can be fixed?

On Feb 16, 3:04 pm, Bayle <bayle.sha...@gmail.com> wrote:
> hi, i'm trying to install pylons on google app engine 1.1.9.
>
> I followed the directions onhttp://wiki.pylonshq.com/display/pylonscookbook/Creating+a+Pylons+app...
>
> However, when I attempt to accesshttp://localhost:8080/, I get the
> svn checkouthttp://appengine-monkey.googlecode.com/svn/trunk

Bayle

unread,
Mar 9, 2009, 2:01:25 AM3/9/09
to pylons-discuss
Did the solution in my previous posts in this thread (http://
groups.google.com/group/pylons-discuss/msg/736a388d21c206ec and
http://groups.google.com/group/pylons-discuss/msg/ed62a408ebe40ae3 ;
basically, to get rid of the "'module' object has no attribute
'find_module'" error, as root, I installed the unpacked version of
setuptools-0.6c9-
py2.5.egg to /usr/lib/python2.5/site-packages/. Then to get rid of the
error concerning "site", in paste-deploy.py, I moved the
command "import site" below the place where sys.path is altered.
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages