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
  • 5,290
  • 16
  • 48
  • 71
Amir
  • 937
  • 3
  • 11
  • 29

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
  • 24,264
  • 10
  • 66
  • 98