> On Tuesday, March 1, 2011, iRick <alexye...@gmail.com> wrote:
> > hi,i'm a freshman for python. i got a problem about "Modules"
Python-related questions should go to comp.lang.python.
> > this is my dir
> > A/
> > a.py
> > __init__.py
> > B/
> > __init__.py
> > b.py
> > C/
> > __init__.py
> > c.py
>
> > and i wrote this as follows in c.py
>
> > from A.B import b
> > ~~~~blablabla
>
> > but the compiler warned like this:
The interpreter, actually.
> > Traceback (most recent call last):
> > File "H:\workspace\A\B\b.py", line 1, in <module>
> > from A.C import c
> > ImportError: No module named A.C
>
> > so what's the matter ? should i do sth in sys.path or
> > someelse?
What you need is to have the directory *containing* A in your
sys.path, but it's usually better not to mess with sys.path directly -
setting your PYTHON_PATH environnment variable would be better.
Also, remember that 1/ the current working directory is automagically
inserted in your sys.path and 2/ Python now has relative imports.
> > i hope sb can help me with it thanks
>
>
> yes, add directory A to sys.path
And this is why it's better to ask python-related questions on
comp.lang.py. Nope, adding A to sys.path will NOT cure the problem -
it's the directory containing A that needs to be in sys.path.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment