python program not running from different folders

vivek at cs.unipune.ernet.in vivek at cs.unipune.ernet.in
Fri Sep 12 08:51:48 EDT 2003


On Fri, Sep 12, 2003 at 02:59:50PM +0300, Jozsa Boti wrote:
> 
> ----- Original Message -----
> From: <vivek at cs.unipune.ernet.in>
> To: "Jozsa Boti" <jboti at integrasoft.ro>
> Cc: <python-list at python.org>
> Sent: Friday, September 12, 2003 2:38 PM
> Subject: Re: python program not running from different folders
> 
> 
> > On Fri, Sep 12, 2003 at 02:20:43PM +0300, Jozsa Boti wrote:
> > > Hi!
> > >
> > > I have a strange problem: I wrote a program in python, and I get an
> error: ImportError: dynamic module does not define init function
> (initESSClientAPI) but only if I run the program in certain folders. The
> same program runs without any error from other folders. Any ideas?
> > >
> >
> > As u have described it seems that the folder from which u are trying to
> run the
> > script contains some dll/so which have the same name as one of the modules
> u are
> > using in your script.
> >
> > eg. like in your script u have:
> >
> > import xyz
> > #call some function from xyz
> > xyz.funct()
> >
> > here xyz is some python module u are using.
> >
> > but as the error message says it may be that the particular folder from
> which
> > the script gives ImportError contains some dll/so with the same name i.e.
> > xyz.dll or xyz.so.
> >
> > Still it is just a wild guess :-)
> >
> > Regards
> > Vivek Kumar
> 
> Thanks for the tip!
> This was the problem indeed. I had a dll written in C++, which is needed by
> another application, once that dll was removed, the program was running
> without any error.
> My concern is how can I overcome this error without renaming some files?
> 
> Boti

In that case you better place you script in a separate folder and make sure that
that particular dll in not in the system path, coz it is mainly a path related
problem. When u import a module then first of all the current folder is
searched for the module, so if u want to keep ur script and the dll in the 
same folder then AFAIK u are out of luck.

Regards
Vivek Kumar





More information about the Python-list mailing list