diff --git a/tests/hghave.py b/tests/hghave.py
index a77338d2bdabb7aa81bb275b3794de7707843545_dGVzdHMvaGdoYXZlLnB5..ca0cd0a135141e1e4507f8f540a8bd3627089c59_dGVzdHMvaGdoYXZlLnB5 100644
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -829,6 +829,17 @@
     return os.path.exists('/dev/full')
 
 
+@check("ensurepip", "ensurepip module")
+def has_ensurepip():
+    try:
+        import ensurepip
+
+        ensurepip.bootstrap
+        return True
+    except ImportError:
+        return False
+
+
 @check("virtualenv", "Python virtualenv support")
 def has_virtualenv():
     try:
diff --git a/tests/test-install.t b/tests/test-install.t
index a77338d2bdabb7aa81bb275b3794de7707843545_dGVzdHMvdGVzdC1pbnN0YWxsLnQ=..ca0cd0a135141e1e4507f8f540a8bd3627089c59_dGVzdHMvdGVzdC1pbnN0YWxsLnQ= 100644
--- a/tests/test-install.t
+++ b/tests/test-install.t
@@ -241,8 +241,11 @@
 shell environment in order to make the virtualenv work reliably.
 
 On Python 3, we use the venv module, which is part of the standard library.
+But some Linux distros strip out this module's functionality involving pip,
+so we have to look for the ensurepip module, which these distros strip out
+completely.
 On Python 2, we use the 3rd party virtualenv module, if available.
 
   $ cd $TESTTMP
   $ unset PYTHONPATH
 
@@ -244,9 +247,9 @@
 On Python 2, we use the 3rd party virtualenv module, if available.
 
   $ cd $TESTTMP
   $ unset PYTHONPATH
 
-#if py3
+#if py3 ensurepip
   $ "$PYTHON" -m venv installenv >> pip.log
 
 Note: we use this weird path to run pip and hg to avoid platform differences,