Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions airflow/operators/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@

def is_venv_installed() -> bool:
"""
Check if the virtualenv package is installed via checking if it is on the path or installed as package.
Check if the virtualenv package is installed by importing `virtualenv`.

:return: True if it is. Whichever way of checking it works, is fine.
:return: True if no `ModuleNotFoundError` is raised, False otherwise.
"""
if shutil.which("virtualenv") or importlib.util.find_spec("virtualenv"):
try:
import virtualenv
return True
return False
except ModuleNotFoundError:
return False



def task(python_callable: Callable | None = None, multiple_outputs: bool | None = None, **kwargs):
Expand Down