I have the project structure:
/hdfs-archiver
/logs
/qe
__init__.py
/tests
__init__.py
archiver.py
/utils
__init__.py
HdfsConnector.py
I am trying to run archiver.py
but I am getting this error:
Traceback (most recent call last):
File "qe/tests/HdfsArchiver.py", line 8, in <module>
from qe.utils import HdfsConnector
ImportError: No module named qe.utils
I read around and it seemed like most people that come across this issue fixed it with __init__.py
when I pwd
:
$ pwd
/Users/bli1/Development/QE/idea/hdfs-archiver
my PYTHONPATH
in .bashrc
export PYTHONPATH=$PYTHONPATH:/Users/bli1/Development/QE/idea/hdfs-archiver
I also tried having my PYTHONPATH
as
/Users/bli1/Development/QE/idea/hdfs-archiver/qe
python ~/Development/QE/idea/hdfs-archiver/qe/tests/archiver.py
or are you typingpython archiver.py
?qe
directory and I am runningpython tests/archiver.py
. Ideally I could like to be able to runarchiver.py
from any directory and still have it work so long as I provide the correct path toarchiver.py
__init__.py
in thehdfs-archiver
directory (root).qe
module is not in your PYTHONPATH variable, which is why the import is not working. You can get around this, by doing a relative import.