2

I am trying to import module named "google" from a custom folder (inside google_appengine folder).

import sys
sys.path.append("/home/sashko/WebProgramming/google_appengine")
import google.appengine.api

But there is already a module named "google" in sys.path:

import google
print google.__path__

['/usr/lib/python2.7/dist-packages/google']

And it shadows module "google" from the custom folder. What would you suggest in such cases?

Harshal Patil
  • 6,284
  • 8
  • 37
  • 55
Sashko Lykhenko
  • 1,262
  • 3
  • 15
  • 33

1 Answers1

5

Insert the path at the start of sys.modules:

sys.path.insert(0, "/home/sashko/WebProgramming/google_appengine")

Now the google_appengine directory will be consulted before the dist-packages location.

Martijn Pieters
  • 889,049
  • 245
  • 3,507
  • 2,997