ache "sys.path_importer_cache") . The
` __path__  ` attributes on package objects are also used. These provide
additional ways that the import machinery can be customized.

[ ` sys.path  ` ](../library/sys.html#sys.path "sys.path") contains a list of
strings providing search locations for modules and packages. It is initialized
from the  [ ` PYTHONPATH  ` ](../using/cmdline.html#envvar-PYTHONPATH)
environment variable and various other installation- and implementation-
specific defaults. Entries in [ ` sys.path  ` ](../library/sys.html#sys.path
"sys.path") can name directories on the file system, zip files, and
potentially other âlocationsâ (see the [ ` site  `
](../library/site.html#module-site "site: Module responsible for site-specific
configuration.") module) that should be searched for modules, such as URLs, or
database queries. Only strings should be present on [ ` sys.path  `
](../library/sys.html#sys.path "sys.path") ; all other data types are ignored.

The [ path based finder  ](../glossary.html#term-path-based-finder) is a [
meta path finder  ](../glossary.html#term-meta-path-finder) , so the import
machinery begins the [ import path  ](../glossary.html#term-import-path)
search by calling the path based finderâs [ ` find_spec()  `
](../library/importlib.html#importlib.machinery.PathFinder.find_spec
"importlib.machinery.PathFinder.find_spec") method as described previously.
When the ` path  ` argument to [ ` find_spec()  `
](../library/importlib.html#importlib.machinery.PathFinder.find_spec
"importlib.machinery.PathFinder.find_spec") is given, it will be a list of
string paths to traverse - typically a packageâs ` __path__  ` attribute for
an import within that package. If the ` path  ` argument is ` None  ` , this
indicates a top level import and [ ` sys.path  `
](../library/sys.html#sys.path "sys.path") is used.

The path based finder iterates over every entry in the search path, and for
each of these, looks for an appropriate [ path entry finder
](../glossary.html#term-path-entry-finder) ( [ ` PathEntryFinder  `
](../library/importlib.html#importlib.abc.PathEntryFinder
"importlib.abc.PathEntryFinder") ) for the path entry. Because this can be an
expensive operation (e.g. there may be ` stat()  ` call overheads for this
search), the path based finder maintains a cache mapping path entries to path
entry finders. This cache is maintained in [ ` sys.path_importer_cache  `
](../library/sys.html#sys.path_importer_cache "sys.path_importer_cache")
(despite the name, this cache actually stores finder objects rather than being
limited to [ importer  ](../glossary.html#term-importer) objects). In this
way, the expensive search for a particular [ path entry
](../glossary.html#term-path-entry) locationâs [ path entry finder
](../glossary.html#term-path-entry-finder) need only be done once. User code
is free to remove cache entries from [ ` sys.path_importer_cache  `
](../library/sys.html#sys.path_importer_cache "sys.path_importer_cache")
forcing the path based finder to perform the path entry search again.

If the path entry is not present in the cache, the path based finder iterates
over every callable in [ ` sys.path_hooks  `
](../library/sys.html#sys.path_hooks "sys.path_hooks") . Each of the [ path
entry hooks  ](../glossary.html#term-path-entry-hook) in this list is called
with a single argument, the path entry to be searched. This callable may
either return a [ path entry finder  ](../glossary.html#term-path-entry-
finder) that can handle the path entry, or it may raise [ ` ImportError  `
](../library/exceptions.html#ImportError "ImportError") . An [ ` ImportError
` ](../library/exceptions.html#ImportError "ImportError") is used by the path
based finder to signal that the hook cannot find a [ path entry finder
](../glossary.html#term-path-entry-finder) for that [ path entry
](../glossary.html#term-path-entry) . The exception is ignored and [ import
path  ](../glossary.html#term-import-path) iteration continues.