Hi I am programming a little script that makes use of a module I developed before. The utils are inside the directory src of the directory utils, and the package is nutum.utils. The script is in the directory src inside the directory sysinfo, and the package is nutum.sysinfo. Well, if not clear, this is the list of files:
ls -lR ~/workspace (imaginary output): utils/src/nutum/__init__.py utils/src/nutum/utils/__init__.py utils/src/nutum/utils/general.py utils/src/nutum/utils/elapsed_time.py utils/src/nutum/utils/execute_command.py utils/src/nutum/utils/size_units.py sysinfo/src/nutum/__init__.py sysinfo/src/nutum/sysinfo/__init__.py sysinfo/src/nutum/sysinfo/sysinfo.py sysinfo/src/nutum/sysinfo/modules/__init__.py sysinfo/src/nutum/sysinfo/modules/base_module.py sysinfo/src/nutum/sysinfo/modules/os.py So, when from the home directory I run this command: PYTHONPATH=workspace/utils/src/:workspace/sysinfo/src python -m nutum.sysinfo.sysinfo --config-file /home/juan/sysinfo.config.ini I get this output: Traceback (most recent call last): File "/usr/lib/python2.5/runpy.py", line 85, in run_module loader = get_loader(mod_name) File "/usr/lib/python2.5/pkgutil.py", line 456, in get_loader return find_loader(fullname) File "/usr/lib/python2.5/pkgutil.py", line 466, in find_loader for importer in iter_importers(fullname): File "/usr/lib/python2.5/pkgutil.py", line 422, in iter_importers __import__(pkg) ImportError: No module named sysinfo Also, if I run this similar command: PYTHONPATH=workspace/utils/src/:workspace/sysinfo/src python workspace/ sysinfo/src/nutum/sysinfo/sysinfo.py --config-file /home/juan/ sysinfo.config.ini The output is this: No module named sysinfo.modules.os Traceback (most recent call last): File "workspace/sysinfo/src/nutum/sysinfo/sysinfo.py", line 156, in <module> classinstance = get_class(class_name)() File "/home/juan/workspace/utils/src/nutum/utils/general.py", line 44, in get_class aClass = get_func(fullClassName) File "/home/juan/workspace/utils/src/nutum/utils/general.py", line 27, in get_func aMod = get_mod(modPath) File "/home/juan/workspace/utils/src/nutum/utils/general.py", line 14, in get_mod aMod = __import__(modulePath, globals(), locals(), ['']) ImportError: No module named sysinfo.modules.os Why this does happens? Why Python does not find the modules if they are already in the path? Why (in the second example) tries to find the module "sysinfo.modules.os" when I am really importing the module "nutum.sysinfo.modules.os" Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list