Setting PYTHONPATH does not allow importing module

faruk at vt.edu faruk at vt.edu
Tue Mar 3 22:47:28 EST 2015


On Tuesday, March 3, 2015 at 10:43:27 PM UTC-5, Zachary Ware wrote:
> On Tue, Mar 3, 2015 at 9:25 PM,  <fa... at vt.edu> wrote:
> > I have the following directory /home/me/projects/modulename.
> >
> > I update PYTHONPATH using the following command:
> > export PYTHONPATH=$PYTHONPATH:/home/me/projects/modulename
> >
> > It seems to have been added:
> > [me at machine ~]$ python -c "import sys; print(sys.path)"
> > ['',... '/home/me', '/home/me/projects/modulename', ...]
> >
> > But import modulename does not work:
> > [me at machine ~]$ python -c "import modulename"
> > Traceback (most recent call last):
> >   File "<string>", line 1, in <module>
> > ImportError: No module named modulename
> >
> > Does anyone know what's wrong?
> 
> Try adding /home/me/projects to PYTHONPATH instead of
> /home/me/projects/modulename.
> 
> -- 
> Zach

Ah, that worked! Yes, I see that the modulename must be visible. Thanks a lot!



More information about the Python-list mailing list