tags:

views:

28

answers:

2
import sys
print sys.path

['D:\\zjm_code\\register2', 'C:\\WINDOWS\\system32\\python25.zip', 'D:\\Python25\\DLLs', 'D:\\Python25\\lib', 'D:\\Python25\\lib\\plat-win', 'D:\\Python25\\lib\\lib-tk', 'D:\\Python25', 'D:\\Python25\\lib\\site-packages']

and

#from django.core.management import setup_environ
from register2 import settings
#setup_environ(settings)

Traceback (most recent call last):
  File "D:\zjm_code\register2\b.py", line 4, in <module>
    from register2 import settings
ImportError: No module named register2

why ,

thanks

+5  A: 

When directory 'D:\\zjm_code\\register2' is on sys.path, this means you can import modules and packages that are INSIDE that directory.

To import the directory register2 itself, two conditions:

  1. its parent, 'D:\\zjm_code', must be on sys.path; and
  2. file 'D:\\zjm_code\\register2\\__init__.py' must exist

__init__.py is the code that actually executes when you "import the directory".

Alex Martelli
A: 

lol because it tries to import something from register2 but it cannot since there isn't D:\zjm_code on the path..

Michał Ludwiński