From 236a6c4522128b51e456ff1ac1062dd5c490fc8a Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Mon, 30 Jul 2018 15:37:10 +0800 Subject: [PATCH] Ignore OSError in is_virtual_environment check This works around a faulty virtual environment on my machine that makes os.access throw "OSError: too many level of symlinks". If a virtual environment is faulty, we can just ignore it. --- pipenv/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pipenv/utils.py b/pipenv/utils.py index 9cf62366..d07d36ab 100644 --- a/pipenv/utils.py +++ b/pipenv/utils.py @@ -1350,8 +1350,12 @@ def is_virtual_environment(path): if not path.is_dir(): return False for bindir_name in ('bin', 'Scripts'): - for python_like in path.joinpath(bindir_name).glob('python*'): - if python_like.is_file() and os.access(str(python_like), os.X_OK): + for python in path.joinpath(bindir_name).glob('python*'): + try: + exeness = python.is_file() and os.access(str(python), os.X_OK) + except OSError: + exeness = False + if exeness: return True return False