Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # just test for a single pyd file that I removed from a non-zipped folder
- class CustomImporter(object):
- virtual_name = 'pandas._libs.tslib' # a pyd file
- def find_module(self, fullname, path=None):
- if fullname == self.virtual_name:
- return self
- return None
- def load_module(self, fullname):
- if fullname in sys.modules:
- return sys.modules[fullname]
- if fullname != self.virtual_name:
- raise ImportError(fullname)
- try:
- path = r"C:.....tslib.cp35-win_amd64.pyd"
- module = imp.load_dynamic("tslib",path )
- module.__file__ = path
- module.__loader__ = self
- module.__name__ = self.virtual_name
- sys.modules[self.virtual_name] = module
- except BaseException as e:
- raise ImportError(fullname + str(e))
- return module
- sys.meta_path.append(CustomImporter())
Add Comment
Please, Sign In to add comment