0

I have folder structure as follows:

/foo/trunk/mss/cloud

and

/foo/trunk/mss/model

my python file is located at subfolder model with name test.py I want to import all modules located in subfolder cloud so my code in test.py is:

import mss.cloud as cloud

but I got an error:

ImportError: No module named mss.clould

should I make any change on PYTHONPATH or anything else? any help is really appreciated.

Vikrant
  • 4,920
  • 17
  • 48
  • 72
Amir
  • 1,017
  • 4
  • 14
  • 32

1 Answers1

0

A way to achieve it is to add the relative path to sys.path, for example:

$ find .
.
./cloud
./cloud/foo.py
./model
./model/t.py


$ cat cloud/foo.py
print 'greetings from', __name__

$ cat model/t.py 
import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'cloud'))    
import foo

$ python model/t.py 
greetings from foo
piokuc
  • 25,594
  • 11
  • 72
  • 102