Newbie question about importing modules.

Jony Zhu jonyzhu at 163.com
Thu Dec 16 23:36:01 EST 2010


Hi, cronoklee
maybe you should check every module directory you want to import to see if  
there is a __init__.py in it?
missing a __init__.py file would cause error when you try to import the  
directory as a module.


在 Fri, 17 Dec 2010 11:42:48 +0800,cronoklee <cronoklee at gmail.com> 写道:

> Hi
> I'm starting my first python project but I'm having trouble getting
> off the ground.
> I've read all I can find about relative and absolute import paths but
> it's just not making sense to me... There seems to be around ten
> different ways to import a script.
>
> I need my project to be portable so I can copy the whole folder to run
> on any PC that has python installed. Is it always possible to simply
> include modules in the project directory and reference them without
> installing into the main python directory? I've managed this with
> small classes through trial and error but when I try it with anything
> larger (like PIL module for example) I get errors. Do I need to
> actually install anything or is it enough just to include the relevant
> scripts?
>
> All the modules I've found come with tonnes of files and
> subdirectories. Do I need all these files or should I just choose the
> scripts/folders I need?
>
> Thanks,
> cronoklee


-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/




More information about the Python-list mailing list