[BangPypers] How to run *.py scripts which interfaces with modules

स्वक्ष vid at svaksha.com
Wed Jul 14 16:13:49 CEST 2010


On Wed, Jul 14, 2010 at 18:04, Naresh Khalasi <nkhalasi at vayana.in> wrote:
> Hi,
>
> The root directory (where your package starts) should be added to PYTHONPATH
> environment variable.
> e.g. if your root directory is /home/<username>/projects/mailman
> export PYTHONPATH=$PYTHONPATH:/home/<username>/projects/mailman
>
> Once you do that you "cd" in the project directory and execute by saying
> python Mailman/Bouncers/BouncerAPI.py <args>

Thanks for replying but I am able to execute independent python
programs. So that's not what my earlier query was all about.

Retrying, with another MM example:
http://bazaar.launchpad.net/~mailman-coders/mailman/2.1/annotate/head:/Mailman/Archiver/Archiver.py,
where the Archiver.py file will import the following program/  modules
to run.

from Mailman import Mailbox
from Mailman import Utils
from Mailman import Site
from Mailman.SafeDict import SafeDict
from Mailman.Logging.Syslog import syslog
from Mailman.i18n import _ ,

This results in the "ImportError" (mentioned earlier).

Besides "from Mailman import Mailbox" in turn refers to email and its
path is: sys.path.append("/home/<$user>/mailman-2.1.10/misc/email-2.58/email/").

So if I set this path inside each of of these *.pyfiles,  using   ---
sys.path.append("/home/<$user>/mailman-2.1.10/Mailman/")  command,
etc...  <==  I'm able to test-run it. But without the path setting,
the program fails throwing errors.

Editing each *.py file to append it with "sys.path" is a tedious
process. So I'd like to know, whether there exists a better method to
set the path externally without changing each program file?  I'd like
to execute these programs independently.

Hope that explains my earlier query a bit more.

TIA,
--
peace,
vid || http://svaksha.com


More information about the BangPypers mailing list