diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-11-05 00:00:48 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-11-05 00:00:48 +0100 |
commit | 2bddd7b15f73f8a063bff3ee1eaa0d1fdaa8cbe9 (patch) | |
tree | 4f73e93d652af60e104262b5058fce871d8516b0 | |
parent | d262c71b006c6202bcdc48f96c3d23a1578853fc (diff) | |
parent | 58c4b3dea4f575e4ae6c51bcd650335ace382059 (diff) | |
download | psutil-2bddd7b15f73f8a063bff3ee1eaa0d1fdaa8cbe9.tar.gz |
Merge branch 'master' into oneshot
-rw-r--r-- | HISTORY.rst | 4 | ||||
-rw-r--r-- | psutil/__init__.py | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/HISTORY.rst b/HISTORY.rst index 84040338..40210247 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -5,6 +5,10 @@ *XXXX-XX-XX* +**Enhncements** + +- 943_: better error message in case of version conflict on import. + **Bug fixes** - 932_: [NetBSD] net_connections() and Process.connections() may fail without diff --git a/psutil/__init__.py b/psutil/__init__.py index 904cf080..2c0954c9 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -205,8 +205,16 @@ _timer = getattr(time, 'monotonic', time.time) if (int(__version__.replace('.', '')) != getattr(_psplatform.cext, 'version', None)): msg = "version conflict: %r C extension module was built for another " \ - "version of psutil (different than %s)" % (_psplatform.cext.__file__, - __version__) + "version of psutil" % getattr(_psplatform.cext, "__file__") + if hasattr(_psplatform.cext, 'version'): + msg += " (%s instead of %s)" % ( + '.'.join([x for x in str(_psplatform.cext.version)]), __version__) + else: + msg += " (different than %s)" % __version__ + msg += "; you may try to 'pip uninstall psutil', manually remove %s" % ( + getattr(_psplatform.cext, "__file__", + "the existing psutil install directory")) + msg += " or clean the virtual env somehow, then reinstall" raise ImportError(msg) |