Skip to content Skip to sidebar Skip to footer

Import Failed When The Module Is Already In The Sys.path

It's weird to me that the import fails even when it's in the sys.path. today, I set up a google app engine django environment on ubuntu in my lab's pc. And it works fine when I che

Solution 1:

Can you import google and google.appengine? Are you sure interpreter has read and traverse access rights to the module tree?

Solution 2:

I had the same problem on Ubuntu when I wanted to play with google.appengine in console. First I tried to fix it by removing the /usr/lib/python2.7/dist-packages/google package altogether but Ubuntu One complained. Finally I resolved it by merging the GAE SDK google package into the package that caused the collision.

The contents of the /usr/lib/python2.7/dist-packages/google dir now look like this:

/google
    /appengine
    /net
    /protobuf
    /pyglib
    /storage
    /__init__.py
    /__init__.pyc

Solution 3:

Looks like you're getting a module (or package) called 'google' from elsewhere -- perhaps /home/tower/googlecode/mygae -- and THAT google module has no appengine in it. To check, print google.__file__ and if possible google.__path__; that should be informative.

Solution 4:

Sometimes you can get an import error for a module when the error is something different, like a syntax error. Try putting

import pdb;pdb.set_trace()

just before the import and then s(tep) into the import, and n(ext) thruogh the module in question to see of you get an error.

Post a Comment for "Import Failed When The Module Is Already In The Sys.path"