Python: Import Module with Wing IDE

VincentH picture VincentH · Dec 26, 2012 · Viewed 7k times · Source

I am new to Python and I have trouble to import modules with Wing IDE/Python 2.7/Mac OS

I have read: Import module from other directory in Wing Ide

and: http://docs.python.org/2/tutorial/modules.html

but still I don't get it.

If, as presented in the second link, I create a fibo.py script and save it in my Python Path then when I try to import it, I have the following error:

import fibo
Traceback (most recent call last):
File "<string>", line 1, in <fragment>
ImportError: No module named fibo

although fibo is available for auto-completion when I type

import 

What did I miss? Thanks for your answers

Answer

Wingware picture Wingware · Dec 26, 2012

That error indicates that the module is not found on the path, so either it's in the wrong place or the path is not what you think it is. You can look at sys.path (after 'import sys') to see the path.

I'm not certain why Wing is offering auto-completion there. One possibility is that you've modified your Python Path in Project Properties (or Configure Python dialog in Wing 101) and have not yet restarted the Python Shell from its Options menu.