ant <a...@anthive.com> writes: > ... > in order to get this far below i had to edit each > file and put a try: except: around each import > statment checking if the module could be found > like (as an example): > > try: > import config as cfg > except: > import frog.config as cfg
Is "frog" the package, you want to install? Then always use "import frog.config ...". Python locates (top level) packages/modules via the so called "Python path" (--> "sys.path"). When you run a script, the "Python path" is extended by the directory the script resides in -- thus a script typically can import "local" packages/module (residing in its directory). However, it is good practise to always access installed packages via their "official package path" (which in your case likely means "frog.config"). When you develop a package, it may not yet be installed. This might hinder you to import in the "official" way. I work around this by using "setuptools" and its "setup" function in my "setup.py". "setuptools" supports the command "develop" (activated via "python setup.py develop") which "installs" the package in a way that it refers to the developped sources. This way, I can always import in the "official" way and nevertheless all my changes are effective immediately. Another approach would be to lay out your package in such a way that it refects the installed structure and for testing put your script in the directory containing your top level packages (or extend "sys.path" with this directory). -- https://mail.python.org/mailman/listinfo/python-list