1

I have a directory structure for a module like the following:

- foo
   - __init__.py
   - gui.py

I use the foo module from other places. Now I want to use something from the foo module in gui.py, but when I try to, I get this:

jsternberg@aquila:~$ python foo/gui.py 
Traceback (most recent call last):
  File "foo/gui.py", line 3, in <module>
    import foo
ImportError: No module named foo

How do I get the foo module from inside of it?

1
  • You're already there. Just import whatever you want to import... Commented Feb 11, 2011 at 4:56

1 Answer 1

2

The directory containing foo/ isn't in sys.path when you invoke it that way.

python -m foo.gui
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.