This is not what is happening to you, but I include it because it is another common class of problems you have when importing a compiled library. You may get an error message which indicates that the library load failed for another reason, like:
Importerror Dll Load Failed The Specified Path Is Invalid
Find the loader for a module, optionally within the specified path. If themodule is in sys.modules, then sys.modules[name].__loader__ isreturned (unless the loader would be None or is not set, in which caseValueError is raised). Otherwise a search using sys.meta_pathis done. None is returned if no loader is found.
A dotted name does not have its parents implicitly imported as that requiresloading them and that may not be desired. To properly import a submodule youwill need to import all parent packages of the submodule and use the correctargument to path.
An abstract method for finding a loader for the specifiedmodule. Originally specified in PEP 302, this method was meantfor use in sys.meta_path and in the path-based import subsystem.
An abstract method for finding a spec forthe specified module. If this is a top-level import, path willbe None. Otherwise, this is a search for a subpackage ormodule and path will be the value of __path__ from theparent package. If a spec cannot be found, None is returned.When passed in, target is a module object that the finder mayuse to make a more educated guess about what spec to return.importlib.util.spec_from_loader() may be useful for implementingconcrete MetaPathFinders.
A legacy method for finding a loader for the specifiedmodule. If this is a top-level import, path will be None.Otherwise, this is a search for a subpackage or module and pathwill be the value of __path__ from the parentpackage. If a loader cannot be found, None is returned.
An abstract method for finding a spec forthe specified module. The finder will search for the module onlywithin the path entry to which it is assigned. If a speccannot be found, None is returned. When passed in, targetis a module object that the finder may use to make a more educatedguess about what spec to return. importlib.util.spec_from_loader()may be useful for implementing concrete PathEntryFinders.
A legacy method for finding a loader for the specifiedmodule. Returns a 2-tuple of (loader, portion) where portionis a sequence of file system locations contributing to part of a namespacepackage. The loader may be None while specifying portion tosignify the contribution of the file system locations to a namespacepackage. An empty list can be used for portion to signify the loaderis not part of a namespace package. If loader is None andportion is the empty list then no loader or location for a namespacepackage were found (i.e. failure to find anything for the module).
An abstract method to return the source of a module. It is returned asa text string using universal newlines, translating allrecognized line separators into '\n' characters. Returns Noneif no source is available (e.g. a built-in module). RaisesImportError if the loader cannot find the module specified.
Class method that attempts to find a specfor the module specified by fullname on sys.path or, ifdefined, on path. For each path entry that is searched,sys.path_importer_cache is checked. If a non-false objectis found then it is used as the path entry finder to lookfor the module being searched for. If no entry is found insys.path_importer_cache, then sys.path_hooks issearched for a finder for the path entry and, if found, is storedin sys.path_importer_cache along with being queried aboutthe module. If no finder is ever found then None is bothstored in the cache and returned.
A class method which returns a closure for use on sys.path_hooks.An instance of FileFinder is returned by the closure using thepath argument given to the closure directly and loader_detailsindirectly.
Find the spec for a module, optionally relative tothe specified package name. If the module is in sys.modules,then sys.modules[name].__spec__ is returned (unless the spec would beNone or is not set, in which case ValueError is raised).Otherwise a search using sys.meta_path is done. None isreturned if no spec is found.
A factory function for creating a ModuleSpecinstance based on the path to a file. Missing information will be filled inon the spec by making use of loader APIs and by the implication that themodule will be file-based.
For deep customizations of import, you typically want to implement animporter. This means managing both the finder and loaderside of things. For finders there are two flavours to choose from depending onyour needs: a meta path finder or a path entry finder. Theformer is what you would put on sys.meta_path while the latter is whatyou create using a path entry hook on sys.path_hooks which workswith sys.path entries to potentially create a finder. This example willshow you how to register your own importers so that import will use them (forcreating an importer for yourself, read the documentation for the appropriateclasses defined within this package):
Traceback (most recent call last): File "inSyncAgent.py", line 42, in File "inSyncLib\inSyncPyQt.pyc", line 4, in File "PyQt4\QtWebKit.pyc", line 12, in File "PyQt4\QtWebKit.pyc", line 10, in __loadImportError: DLL load failed: The specified module could not be found. 2ff7e9595c
Comments