Skip to content

Commit

Permalink
#943: better error message in case of version conflict on import.
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Nov 2, 2016
1 parent 71282df commit 58c4b3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions psutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,16 @@
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)


Expand Down

0 comments on commit 58c4b3d

Please sign in to comment.