Pipenv fails with distutils package is deprecated

  distutils, pipenv, python, python-3.8

Pipenv fails creating virtualenv with error below.
Any solution on how to solve this?

❯ pipenv shell
Creating a virtualenv for this project...
Pipfile: /home/xxx/Pipfile
Using /usr/bin/python3 (3.10.0) to create virtualenv...
⠹ Creating virtual environment...
RuntimeError: failed to query /usr/bin/python3 with code 1 err:
'/usr/local/lib/python3.8/dist-packages/virtualenv/discovery/py_info.py:16: 
DeprecationWarning: The distutils package is deprecated and slated for removal
in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils import dist

Traceback (most recent call last):n  
File "/usr/local/lib/python3.8/dist-packages/virtualenv/discovery/py_info.py",
    line 16, in <module> from distutils import dist
ImportError: cannot import name 'dist'
    from 'distutils' (/usr/lib/python3.10/distutils/__init__.py)n'

✘ Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]:
Failed to create virtual environment.

System parameters:

❯ python --version
Python 3.8.10
❯ uname  -a
Linux mine 5.11.0-38-generic #42~20.04.1-Ubuntu SMP Tue Sep 28 20:41:07 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Source: Python Questions

LEAVE A COMMENT