0

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

enter image description here

I added __init__.py within directories tests and utils as well but same error occurs

1
  • Ever solved this? I'm having similar issues (on Windows 10). Commented Feb 8, 2017 at 9:36

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Hmmm echo $PYTHONPATH returns nothing =/ I tried exiting all my terminal sessions and still getting empty python path
What does echo $SHELL return?
when you edit you .bashrc, do you then call "source ~/.bashrc" or launch a new shell?
@nicolallias I launch a new shell because I thought bashrc automatically sources upon new shell instance
yes it does, you would have to use the "source" command if you wished to stay in the same shell.
0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.