From abda001fcfc9ad99759ed3ebaeaa884c42f235cd Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 3 Jul 2014 09:16:14 +0530 Subject: [PATCH] Fix importing of C-extensions when people are running from source with a PYTHONPATH containing conflicting pre-imported modules --- src/calibre/constants.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index 9e9e32f8a2..9356f5966f 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -160,6 +160,10 @@ class Plugins(collections.Mapping): if name in self._plugins: return sys.path.insert(0, sys.extensions_location) + try: + del sys.modules[name] + except KeyError: + pass try: p, err = importlib.import_module(name), '' except Exception as err: