summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Fernandez <xavier.fernandez@polyconseil.fr>2015-10-19 17:04:02 +0200
committerXavier Fernandez <xavier.fernandez@polyconseil.fr>2015-10-22 23:15:02 +0200
commit89a27cd7401907fdf7aba01f47c8242f5e279024 (patch)
tree680127688f94e5bdfcccbfca162f37ff631de6f2
parent8cbb8af4660c30e98c9a3949596336a3e00c013a (diff)
downloadpip-89a27cd7401907fdf7aba01f47c8242f5e279024.tar.gz
Special-case based on exception message
-rw-r--r--pip/req/req_install.py11
-rw-r--r--tests/functional/test_install.py4
2 files changed, 11 insertions, 4 deletions
diff --git a/pip/req/req_install.py b/pip/req/req_install.py
index b41411a19..1d5ec5d20 100644
--- a/pip/req/req_install.py
+++ b/pip/req/req_install.py
@@ -344,10 +344,17 @@ class InstallRequirement(object):
try:
import setuptools # noqa
except ImportError as e:
+ # Python 2 and 3 variants:
+ if e.args[0] in (
+ "No module named setuptools",
+ "No module named 'setuptools'"):
+ suggestion = "Please install setuptools."
+ else:
+ suggestion = "Check your setuptools installation: %s" % e
# Setuptools is not available
raise InstallationError(
- "Could not import setuptools (%s) which is required to "
- "install from a source distribution" % e
+ "Could not import setuptools which is required to "
+ "install from a source distribution. %s" % suggestion
)
setup_file = 'setup.py'
diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py
index 69ea940e3..47ca38cd4 100644
--- a/tests/functional/test_install.py
+++ b/tests/functional/test_install.py
@@ -26,8 +26,8 @@ def test_without_setuptools(script, data):
expect_error=True,
)
assert (
- "Could not import setuptools (No module named setuptools) which is "
- "required to install from a source distribution"
+ "Could not import setuptools which is required to install from a "
+ "source distribution."
in result.stderr
)