Eduardo Eduardo - 9 months ago 55
Python Question

python ImportError No module named

I am very new at Python and I am getting this error:

Traceback (most recent call last):
File "", line 28, in ?
from toolkit.interface import interface
ImportError: No module named toolkit.interface

Python is installed in a local directory:

My directory tree is like this:

(local directory)/site-packages/toolkit/

My code is in here

(local directory)/site-packages/toolkit/examples/

To run the example I do
, and in the code I have:

from toolkit.interface import interface

And i get the error that I wrote, I have already checked
and there I have the directory
, also I have the file
in the toolkit folder to indicate to Python that this is a package. I also have a
in the examples directory.

I do not know why Python cannot find the file when it is in
, any ideas? Can be a permissions problem? Do I need execution permission?


Based on your comments to orip's post, I guess this is what happened:

  1. You edited on windows.
  2. The windows editor added something non-printing, perhaps a carriage-return (end-of-line in Windows is CR/LF; in unix it is LF only), or perhaps a CTRL-Z (windows end-of-file).
  3. You used WinSCP to copy the file to your unix box.
  4. WinSCP thought: "This has something that's not basic text; I'll put a .bin extension to indicate binary data."
  5. The missing (now called means python doesn't understand toolkit as a package.
  6. You create in the appropriate directory and everything works... ?