Reputation: 36384
So, I print the sys.path
in the python terminal inside the working python project directory, and find the directory there. I've also put in a __init__.py
in the directory, too.
But when I do a import directoryname
, I get a module not found error.
Where can I possibly be going wrong?
Ok, I found the problem. It is giving a no such directory error when I check the $PYTHONPATH.
This is my PythonPath
export PYTHONPATH=/usr/lib/python2.7/dist-packages:/home/python/softwares/orade
Upvotes: 0
Views: 3835
Reputation: 46566
I assume that you are trying to import the orade
module. PYTHONPATH
represents the path to the directory that contains python modules, not the collection of paths to the modules.
So you should put the parent directory of your module in the PYTHONPATH
. If the path to your module is /home/python/softwares/orade
, you should put /home/python/softwares
in your PYTHONPATH
:
export PYTHONPATH=/usr/lib/python2.7/dist-packages:/home/python/softwares
And then you should be able to do:
>>> import orade
If the orade
directory contains a __init__.py
file.
Upvotes: 3