Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions news/5477.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check if ``venv`` module is available and fallback to prior logic when it is not.
30 changes: 21 additions & 9 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,15 +989,27 @@ def do_create_virtualenv(project, python=None, site_packages=None, pypi_mirror=N
err=True,
)

cmd = [
Path(sys.executable).absolute().as_posix(),
"-m",
"virtualenv",
"--creator=venv",
f"--prompt={project.name}",
f"--python={python}",
project.get_location_for_virtualenv(),
]
try:
import venv # noqa

cmd = [
Path(sys.executable).absolute().as_posix(),
"-m",
"virtualenv",
"--creator=venv",
f"--prompt={project.name}",
f"--python={python}",
project.get_location_for_virtualenv(),
]
except ImportError:
cmd = [
Path(sys.executable).absolute().as_posix(),
"-m",
"virtualenv",
f"--prompt={project.name}",
f"--python={python}",
project.get_location_for_virtualenv(),
]

# Pass site-packages flag to virtualenv, if desired...
if site_packages:
Expand Down