diff --git a/news/3753.trivial.rst b/news/3753.trivial.rst new file mode 100644 index 00000000..2ab71d38 --- /dev/null +++ b/news/3753.trivial.rst @@ -0,0 +1 @@ +Improve the error message of ``pipenv --py`` when virtualenv can't be found. diff --git a/pipenv/core.py b/pipenv/core.py index a30cf8dd..7b00eb59 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -1775,6 +1775,17 @@ def ensure_lockfile(keep_outdated=False, pypi_mirror=None): def do_py(system=False): + if not project.virtualenv_exists: + click.echo( + "{}({}){}".format( + crayons.red("No virtualenv has been created for this project "), + crayons.white(project.project_directory, bold=True), + crayons.red(" yet!") + ), + err=True, + ) + return + try: click.echo(which("python", allow_global=system)) except AttributeError: