Reputation: 16469
I'm not sure why I am still getting an ImportError
Traceback:
Traceback (most recent call last):
File "./test_jabba.py", line 12, in <module>
from tests import testbench
ImportError: No module named tests
Where error occurs:
from tests import testbench
from utils import gopher, jsonstream
I have this in my .bashrc
export PYTHONPATH=$PYTHONPATH:/Users/bli1/Development/QE/TrinityTestFramework/poc
However, when I echo $PYTHONPATH
nothing is returned
I added __init__.py
within directories tests
and utils
as well but same error occurs
Upvotes: 0
Views: 1082
Reputation: 942
Are you sure your .bashrc
is correctly sourced?
If you run in your session
echo $PYTHONPATH
is it correctly set?
If not, try to manually export the path and then try to understand why your .bashrc
is not being sourced. Possible trivial causes:
You are using a shell different than bash, very trivial but might happen. Try to run echo $SHELL
. Note that this might return /bin/bash
even if you are not actually using bash. Please refer to this post to find out which shell you are using. You can also start a new bash session manually (just run /bin/bash
) and double check if PYTHONPATH
is exported correctly there.
You modified your .bashrc
but you didn't start a new session.
Upvotes: 1
Reputation: 399
You should import the module and not the folder. The from something import something command only works for objects in the module file. Python module import error or python module import error should help
Upvotes: 0