Python is installed in a local directory.
My directory tree looks like this:
My code is in here:
To run the example, I write
python mountain.py, and in the code I have:
from toolkit.interface import interface
And I get the error:
Traceback (most recent call last): File "mountain.py", line 28, in ? from toolkit.interface import interface ImportError: No module named toolkit.interface
I have already checked
sys.path and there I have the directory
/site-packages. Also, I have the file
__init__.py.bin in the toolkit folder to indicate to Python that this is a package. I also have a
__init__.py.bin in the examples directory.
I do not know why Python cannot find the file when it is in
sys.path. Any ideas? Can it be a permissions problem? Do I need some execution permission?
Based on your comments to orip’s post, I guess this is what happened:
- You edited
- 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).
- You used WinSCP to copy the file to your unix box.
- WinSCP thought: “This has something that’s not basic text; I’ll put a .bin extension to indicate binary data.”
- The missing
__init__.py.bin) means python doesn’t understand toolkit as a package.
- You create
__init__.pyin the appropriate directory and everything works… ?