Setting PYTHONPATH does not allow importing module
cl at isbd.net
cl at isbd.net
Wed Mar 4 04:14:16 EST 2015
faruk 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
>
Don't you have that one level wrong, to import <modulename> you need
the directory where the name <modulename> is to be on PYTHONPATH.
I.e. you should have:-
export PYTHONPATH=$PYTHONPATH:/home/me/projects/
If you think about it this makes sense!
--
Chris Green
·
More information about the Python-list
mailing list