Module import errors relating to site when using GAE SDK 1.1.3

104 views
Skip to first unread message

Josh Heitzman

unread,
Sep 17, 2008, 4:33:57 PM9/17/08
to pylons-discuss
I just uninstalled GAE SDK 1.1.1 and installed 1.1.3 and when I tried
to run my app I got the following error:

File "c:\Tools\GAE\google\appengine\tools\dev_appserver.py", line
1271, in LoadModuleRestricted
description)
File "d:\Enlistments\Prototypes\webgamesbyjosh\site.py", line 74, in
<module>
__boot()
File "d:\Enlistments\Prototypes\webgamesbyjosh\site.py", line 26, in
__boot
stream, path, descr = imp.find_module('site',[item])
AttributeError: 'module' object has no attribute 'find_module'

If you are wondering why site.py is located at the root of my project,
its because I had wanted to edit the line generating the error:

stream, path, descr = imp.find_module('site',[item])

to just read:

stream = None

to see what happened, but setup tools was installed as zip.

After I deleted it and reinstalled it as flat file I kept getting an
import error regarding site (no I'm not running in an appmonkey
virtual env) even though adding a print >>sys.stderr, sys.path
statement right before import site statement in paste-deploy.py shows
that 'c:\\Tools\\Python25\\lib\\site-packages\\setuptools-0.6c8-
py2.5.egg' is on my path. That directory does have site.py, which is
the source from which I copied site.py into my project root.

Anyway, after I did get the line above edited, the error I get now is:

File "c:\Tools\GAE\google\appengine\tools\dev_appserver.py", line
1271, in LoadModuleRestricted
description)
File "d:\Enlistments\Prototypes\webgamesbyjosh\site.py", line 73, in
<module>
__boot()
File "d:\Enlistments\Prototypes\webgamesbyjosh\site.py", line 38, in
__boot
raise ImportError("Couldn't find the real 'site' module")

Anyone run into anything similar?

Anyone have any clue as to what might be going on here?

Thanks,

Josh Heitzman


Mike Orr

unread,
Sep 17, 2008, 5:02:14 PM9/17/08
to pylons-...@googlegroups.com

No, but maybe you can run it under the Python debugger and see what
that stack frame thinks sys.path and the current directory are, and
whether you can manually import site (and your application) from
there.

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

Josh Heitzman

unread,
Sep 17, 2008, 6:10:51 PM9/17/08
to pylons-discuss
Well for the issue of not being able to find the site module, there a
couple of things going on. First when FindPathHook in
dev_appserver.py calls hook(path_entry) it gets the exception
"zipimport.ZipImportError: not a Zip file", so it may be that
something somewhere (have a search running but haven't found it yet)
has it cached that C:\Tools\Python25\Lib\site-packages
\setuptools-0.6c8-py2.5.egg is a zip file. Have a search going to
locate the culprit there.

Then this code in FindModuleRestricted:

if (file_type not in (self._imp.C_BUILTIN, self._imp.C_EXTENSION)
and
not FakeFile.IsFileAccessible(pathname)):
error_message = 'Access to module file denied: %s' % pathname
logging.debug(error_message)
raise ImportError(error_message)

ends up raising this helpful exception, which then gets masked by a
generic exception by code above.

When I copy site.py back into the root of my project I see that C:
\Tools\Python25\Lib\site-packages\setuptools-0.6c8-py2.5.egg is on the
path, but it isn't available on the path_importer_cache so that's how
the code ends up going down the else to:

else:
try:
stream = stream, path, descr = imp.find_module('site',
[item])

which then failed because imp does not have find_module.

On Sep 17, 2:02 pm, "Mike Orr" <sluggos...@gmail.com> wrote:
> Mike Orr <sluggos...@gmail.com>

Josh Heitzman

unread,
Sep 17, 2008, 7:39:17 PM9/17/08
to pylons-discuss
While debugging through this again, I noticed that the only values in
the path_importer_cache that are not none are those with zip files:

C:\Tools\GAE\lib\django = None
C:\Tools\Python25\DLLs = None
d:\Enlistments\Prototypes\webgamesbyjosh = None
C:\Tools\Python25\lib\site-packages\pastescript-1.3.6-py2.5.egg = None
C:\Tools\Python25\lib\site-packages\webhelpers-0.3.2-py2.5.egg = None
C:\WINDOWS\system32\python25.zip = None
C:\Tools\Python25\lib\site-packages\routes-1.7.3-py2.5.egg = None
C:\Tools\Python25\lib\site-packages\simplejson-1.7.1-py2.5.egg =
"<zipimporter object "C:\Tools\Python25\lib\site-packages\simplejs...
C:\Tools\GAE\lib\yaml\lib = None
C:\Tools\Python25\lib\site-packages\mako-0.1.8-py2.5.egg = None
C:\Tools\Python25\lib\site-packages\pastedeploy-1.3.1-py2.5.egg = None
C:\Tools\GAE\lib\webob = None
C:\Tools\Python25\lib\site-packages\setuptools-0.6c8-py2.5.egg = None
C:\Tools\Python25\lib = None
C:\Tools\Python25\lib\site-packages\elementtree-1.2.7_20070827_preview-
py2.5-win32.egg = "<zipimporter object "C:\Tools\Python25\lib\site-
packages\elementt...
C:\Tools\Python25\lib\site-packages\webob-0.9.2-py2.5.egg = None
C:\Tools\GAE = None
C:\Tools\Python25\lib\site-packages\paste-1.4.2-py2.5.egg = None
C:\Tools\Python25\lib\site-packages\beaker-1.0.1-py2.5.egg = None
C:\Tools\Python25\lib\site-packages\pylons-0.9.6.2-py2.5.egg = None
C:\Tools\Python25\lib\site-packages\formencode-0.7.1-py2.5.egg = None
C:\Tools\Python25\lib\site-packages\nose-0.10.3-py2.5.egg = None
C:\Tools\Python25\lib\site-packages\decorator-2.3.1-py2.5.egg = None
C:\Tools\Python25\lib\site-packages\appcelerator-1.0.6-py2.5.egg =
None

so I'm not sure how this code in site.py is supposed to work seeing as
how it either needs to get the module from the PIC or via
imp.find_module, which isn't actually supported on GAE, it really
needs to come from PIC:

for item in stdpath:
if item==mydir or not item:
continue # skip if current dir. on Windows, or my own
directory
importer = pic.get(item)
if importer is not None:
loader = importer.find_module('site')
if loader is not None:
# This should actually reload the current module
loader.load_module('site')
break
else:
try:
stream, path, descr = imp.find_module('site',[item])
except ImportError:
continue
if stream is None:
continue
try:
# This should actually reload the current module
imp.load_module('site',stream,path,descr)
finally:
stream.close()
break
else:
raise ImportError("Couldn't find the real 'site' module")

Josh Heitzman

unread,
Sep 17, 2008, 9:15:27 PM9/17/08
to pylons-discuss
Well, it turns out this just something wrong with GAE's SDK upgrade
process. I uninstalled 1.1.1 before installing 1.1.3, but apparently
that isn't good enough, as you need to delete what's left in the
directly as well. I figured that out by restoring my hard drive to an
earlier image, installing 1.1.1 verfying my app worked, then
uninstalling it, then deleting what was left, then installing 1.1.3
and now this time it worked just fine.

Can't say I'm pleased that their poorly written installer ate up the
better part of my day, but I'm glad to have my app working again.

Jorge Vargas

unread,
Sep 18, 2008, 4:00:36 AM9/18/08
to pylons-...@googlegroups.com
On Wed, Sep 17, 2008 at 7:15 PM, Josh Heitzman <JoshHe...@hotmail.com> wrote:
>
> Well, it turns out this just something wrong with GAE's SDK upgrade
> process. I uninstalled 1.1.1 before installing 1.1.3, but apparently
> that isn't good enough, as you need to delete what's left in the
> directly as well. I figured that out by restoring my hard drive to an
> earlier image, installing 1.1.1 verfying my app worked, then
> uninstalling it, then deleting what was left, then installing 1.1.3
> and now this time it worked just fine.
>
> Can't say I'm pleased that their poorly written installer ate up the
> better part of my day, but I'm glad to have my app working again.
>
doesn't the SDK updates itself? or the windows one doesn't? maybe you
where not supposed to uninstall the older version first.

Mike Orr

unread,
Sep 18, 2008, 9:37:09 AM9/18/08
to pylons-...@googlegroups.com
On Thu, Sep 18, 2008 at 1:00 AM, Jorge Vargas <jorge....@gmail.com> wrote:
>
> On Wed, Sep 17, 2008 at 7:15 PM, Josh Heitzman <JoshHe...@hotmail.com> wrote:
>>
>> Well, it turns out this just something wrong with GAE's SDK upgrade
>> process. I uninstalled 1.1.1 before installing 1.1.3, but apparently
>> that isn't good enough, as you need to delete what's left in the
>> directly as well. I figured that out by restoring my hard drive to an
>> earlier image, installing 1.1.1 verfying my app worked, then
>> uninstalling it, then deleting what was left, then installing 1.1.3
>> and now this time it worked just fine.
>>
>> Can't say I'm pleased that their poorly written installer ate up the
>> better part of my day, but I'm glad to have my app working again.
>>
> doesn't the SDK updates itself? or the windows one doesn't? maybe you
> where not supposed to uninstall the older version first.

On Linux I just unpack a self-contained tarball, so switching versions
is just a matter of typing a different path to dev_appserver.py, and
one version doesn't know about another's libraries.

GAE wouldn't be the first program that breaks if pieces of the
previous version is lying around, so I'm not surprised you had to
delete the old one completely to get it to work. Maybe the Windows
installer could be improved; I don't know what "what was left" means.
If it's *.pyc files, sometimes Python gets confused and thinks a .pyc
is up to date when it isn't, so just deleting the files corrects this.

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

Josh Heitzman

unread,
Sep 18, 2008, 1:47:38 PM9/18/08
to pylons-discuss
I didn't do any in depth survey, but I definitely saw a number of .pyc
files in what was left behind after uninstalling.

I think it was more then that though, as before re-imaging I had
uninstalled the SDK again, deleted the GAE SDK directory and then
reinstalled. While trying to solve this I noticed the SDK was putting
the datastore in my user temp directory, so I don't know if they've
got some other stuff in there as well that may have been removed when
I restored my backup hard drive image.

On Sep 18, 6:37 am, "Mike Orr" <sluggos...@gmail.com> wrote:
> On Thu, Sep 18, 2008 at 1:00 AM, Jorge Vargas <jorge.var...@gmail.com> wrote:
> Mike Orr <sluggos...@gmail.com>

Josh Heitzman

unread,
Sep 18, 2008, 1:49:17 PM9/18/08
to pylons-discuss
Not automatically on Windows at least. It gave me a message that a
new SDK was available, which I then went and downloaded. When I
started the new install up it didn't indicate it had detected the old
one, so I canceled and uninstalled the old on first, then installed
the new one.

On Sep 18, 1:00 am, "Jorge Vargas" <jorge.var...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages