Re: getting a python module accepted by python?
"Sean 'Shaleh' Perry" <firstname.lastname@example.org> writes:
> When I try to 'import soaplib' in python, I get an error:
> ImportError: No module named soaplib
> anyone know what I am missing?
You should be putting soaplib.py directly into site-packages, instead
of in a directory.
Within the Python path, directories are considered to be packages,
i.e. the file foo/bar.py is imported with "import foo.bar". To be
importable as a package a directory has to have a __init__.py file,
even if it is empty... otherwise, the directory and everything in it
This has implications in the way modules are named, too. For example,
the module .../site-packages/soaplib/soaplib.py is called
"soaplib.soaplib", not just "soaplib". So you must be careful when
reorganizing Python library code, because placing it in a different
place in the naming hierarchy may break other code that uses it.
In this case, this means you should just put soaplib.py in the
site-packages directory -- since it stands alone, or at least it did
last time I looked at it, there is no need to do anything more
complicated than that.
Rob Tillotson N9MTB <email@example.com>