question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pipenv will not create a virtual environment for Python 3.8, but will for 3.7

See original GitHub issue

Be sure to check the existing issues (both open and closed!), and make sure you are running the latest version of Pipenv.

Check the diagnose documentation for common issues before posting! We may close your issue if it is very similar to one of them. Please be considerate, or be on your way.

Make sure to mention your debugging experience if the documented solution failed.

Issue description

When I try to create a pipenv virtual environment with Python 3.8, it fails, with the error message, ModuleNotFoundError: No module name 'distutils.spawn'

Here is the full context:

➜ pipenv --python 3.8                   
Creating a virtualenv for this project…
Pipfile: /home/james/learning/cs-python/Pipfile
Using /usr/bin/python3.8 (3.8.0) to create virtualenv…
⠙ Creating virtual environment...Running virtualenv with interpreter /usr/bin/python3.8

✘ Failed creating virtual environment 
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/james/.local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
[pipenv.exceptions.VirtualenvCreationException]:       return f(get_current_context(), *args, **kwargs)
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/james/.local/lib/python3.6/site-packages/pipenv/cli/command.py", line 208, in cli
[pipenv.exceptions.VirtualenvCreationException]:       clear=state.clear,
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/james/.local/lib/python3.6/site-packages/pipenv/core.py", line 574, in ensure_project
[pipenv.exceptions.VirtualenvCreationException]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/james/.local/lib/python3.6/site-packages/pipenv/core.py", line 506, in ensure_virtualenv
[pipenv.exceptions.VirtualenvCreationException]:       python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
[pipenv.exceptions.VirtualenvCreationException]:   File "/home/james/.local/lib/python3.6/site-packages/pipenv/core.py", line 935, in do_create_virtualenv
[pipenv.exceptions.VirtualenvCreationException]:       extra=[crayons.blue("{0}".format(c.err)),]
[pipenv.exceptions.VirtualenvCreationException]: Traceback (most recent call last):
  File "/home/james/.local/lib/python3.6/site-packages/virtualenv.py", line 24, in <module>
    import distutils.spawn
ModuleNotFoundError: No module named 'distutils.spawn'

Failed to create virtual environment.

When I run `pipenv --python 3.8`, it works!

Expected result

The virtual environment should be created correctly.

When possible, provide the verbose output (--verbose), especially for locking and dependencies resolving issues.

Steps to replicate

Provide the steps to replicate (which usually at least includes the commands and the Pipfile).


Please run $ pipenv --support, and paste the results here. Don’t put backticks (`) around it! The output already contains Markdown formatting.

$ pipenv --support

Pipenv version: '2018.11.26'

Pipenv location: '/home/james/.local/lib/python3.6/site-packages/pipenv'

Python location: '/usr/bin/python3'

Python installations found:

  • 3.8.0: /usr/bin/python3.8
  • 3.7.5: /usr/bin/python3.7
  • 3.7.5: /usr/bin/python3.7m
  • 3.6.8: /usr/bin/python3
  • 3.6.8: /usr/bin/python3.6m
  • 2.7.15: /usr/bin/python

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.6.8',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '5.0.0-29-generic',
 'platform_system': 'Linux',
 'platform_version': '#31~18.04.1-Ubuntu SMP Thu Sep 12 18:29:21 UTC 2019',
 'python_full_version': '3.6.8',
 'python_version': '3.6',
 'sys_platform': 'linux'}

System environment variables:

  • XDG_SEAT
  • XDG_SESSION_ID
  • WINDOWPATH
  • LC_IDENTIFICATION
  • DISPLAY
  • GJS_DEBUG_TOPICS
  • COLORTERM
  • GNOME_TERMINAL_SERVICE
  • GNOME_DESKTOP_SESSION_ID
  • DEFAULTS_PATH
  • LOGNAME
  • TEXTDOMAIN
  • LC_TIME
  • SHELL
  • PAPERSIZE
  • PATH
  • LC_NUMERIC
  • LC_PAPER
  • IM_CONFIG_PHASE
  • TEXTDOMAINDIR
  • CLUTTER_IM_MODULE
  • QT4_IM_MODULE
  • XMODIFIERS
  • XDG_MENU_PREFIX
  • GNOME_SHELL_SESSION_MODE
  • XAUTHORITY
  • XDG_SESSION_DESKTOP
  • GDMSESSION
  • QT_IM_MODULE
  • SSH_AUTH_SOCK
  • LC_ADDRESS
  • LC_MEASUREMENT
  • XDG_CONFIG_DIRS
  • MANDATORY_PATH
  • USERNAME
  • DESKTOP_SESSION
  • XDG_RUNTIME_DIR
  • GTK_IM_MODULE
  • USER
  • GTK_MODULES
  • PWD
  • VTE_VERSION
  • LC_MONETARY
  • HOME
  • QT_ACCESSIBILITY
  • SSH_AGENT_PID
  • XDG_DATA_DIRS
  • LANGUAGE
  • LANG
  • LC_NAME
  • GNOME_TERMINAL_SCREEN
  • GPG_AGENT_INFO
  • SHLVL
  • GJS_DEBUG_OUTPUT
  • XDG_VTNR
  • XDG_SESSION_TYPE
  • DBUS_SESSION_BUS_ADDRESS
  • XDG_CURRENT_DESKTOP
  • TERM
  • SESSION_MANAGER
  • LC_TELEPHONE
  • OLDPWD
  • LS_COLORS
  • SPACESHIP_VERSION
  • SPACESHIP_ROOT
  • NVM_DIR
  • NVM_CD_FLAGS
  • NVM_BIN
  • EDITOR
  • _
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_SHIMS_BASE_MODULE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /home/james/.local/bin:/home/james/.nvm/versions/node/v12.9.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/cuda/bin:/snap/bin
  • SHELL: /usr/bin/zsh
  • EDITOR: emacs -nw
  • LANG: en_US.UTF-8
  • PWD: /home/james/learning/cs-python

Contents of Pipfile (‘/home/james/learning/cs-python/Pipfile’):


Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
notconfusingcommented, Sep 24, 2020

apt install python3.8 made this work for me, when snap install python3.8 didn’t.

0reactions
matteiuscommented, Aug 22, 2022

Can this be rechecked with pipenv==2022.8.19?

Read more comments on GitHub >

github_iconTop Results From Across the Web

pipenv requires python 3.7 but installed version is 3.8 and ...
My way to solve the problem is simply delete the old Pipfile and input pipenv shell in the terminal. Then it will build...
Read more >
Install Python 3.8, Virtual Environments using Pipenv, Django ...
Install Python 3.8, Virtual Environments, Django 3+ on Windows using pipenv, pip (Python Package Installer) and Windows Powershell.
Read more >
How to Manage Python Dependencies with Virtual ...
Multiple Python projects, each with their own dependencies can be effectively managed using separate virtual environments. Pipenv, Venv, and ...
Read more >
Pipenv: Python Dev Workflow for Humans - Read the Docs
You no longer need to use pip and virtualenv separately. They work together. Managing a requirements.txt file can be problematic, so Pipenv uses...
Read more >
Install Python 3.8 on Windows 10 - 4 of 10 - Create ... - YouTube
Install Python Windows - 4 of 10 - Create and Activate a Virtual Environment with PipenvPython on ... Your browser can't play this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found