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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.