[Tutor] How can I add my folder to pythonpath?
lantal at tmail.com
Fri Jun 23 23:25:56 CEST 2006
On 06/23/06 at 2:11 PM you wrote:
> If I understand what you're asking (forgive me if I misunderstood),
> you need to create a file in the mymodules directory and call it
> __init__.py (even if you don't put anything in this file). This tells
> Python that it is a package containing modules. Then, in your program
> myprogram.py, you can say import mymodule1
> Then it shouldn't matter what computer you are on; the script should
> Laszlo Antal wrote:
> >This is how my directory looks
> >myprogram (this is the main folder for my program)
> > myprogram.py
> > mymodules (this is where I store my modules)
> > |
> > mymodule1.py
> > mymodule2.py
> >I would like to import from mymodules folder my modules1.py,
> >mymodules2.py into myprogram.py.
> >How can I add mymodules folder to pythonpath
> >from myprogram.py.?
> >So if I copy myprogram folder into an other pc than
> >myprogram.py can take care of adding mymodules folder to
> >Thank you in advance
> >Laszlo Antal
I tried your suggestion.
I created a file inside mymodules folder called __init__.py.
when i run myprogram.py i still get the same error.
Traceback (most recent call last):
File "/home/laszlo/myprogram/myprogram.py", line 7, in ?
ImportError: No module named mymodule1#
What am I doing wrong?
> >Tutor maillist - Tutor at python.org
More information about the Tutor