Originally I was using pipenv to create a venv with python 3.6 and it was without any issue. The python 3.6 is from anaconda:
Python 3.6.13 |Anaconda, Inc.| (default, Feb 23 2021, 12:58:59)
[GCC Clang 10.0.0 ] on darwin
Type "help", "copyright", "credits" or "license" for more
information.
>>> import sys
>>> sys.executable
'/Users/unhumanWu/anaconda/bin/python'
Then I need to upgrade my python version from 3.6 to 3.9 by changing python version in pipfile then it shows error:
unhumanWu-2:capstone-project unhumanWu$ pipenv shell /usr/local/bin/python3.9
Creating a virtualenv for this project...
Pipfile: /Users/Shared/Learning/Udacity/Udacity-de/capstone-project/Pipfile
Using /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 (3.9.12) to create virtualenv...
⠴ Creating virtual environment...Using base prefix
'/Library/Frameworks/Python.framework/Versions/3.9'
New python executable in
/Users/unhumanWu/.local/share/virtualenvs/capstone-project-YzbI2eRH/bin/python3.9
Not overwriting existing python script
/Users/unhumanWu/.local/share/virtualenvs/capstone-project-YzbI2eRH/bin/python (you must use
/Users/unhumanWu/.local/share/virtualenvs/capstone-project-YzbI2eRH/bin/python3.9)
ERROR: The executable /Users/unhumanWu/.local/share/virtualenvs/capstone-project-YzbI2eRH/bin/python3.9 is not functioning
ERROR: It thinks sys.prefix is '/Library/Frameworks/Python.framework/Versions/3.9' (should be '/Users/unhumanWu/.local/share/virtualenvs/capstone-project-YzbI2eRH')
ERROR: virtualenv is not compatible with this system or executable
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9
✘ Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]:
/Users/unhumanWu/anaconda/lib/python3.6/site-
packages/virtualenv.py:1039: DeprecationWarning: the imp module
is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
Failed to create virtual environment.
To check the issue I use different user (let's say user2) with same pipfile to create the venv again and it generated successfully:
unhuman_dev in /Users/Shared/Learning/Udacity/Udacity-de/capstone-project (master) > pipenv shell
Creating a virtualenv for this project...
Pipfile: /Users/Shared/Learning/Udacity/Udacity-de/capstone-project/Pipfile
Using /usr/local/bin/python3.9 (3.9.12) to create virtualenv...
⠋ Creating virtual environment...created virtual environment CPython3.9.12.final.0-64 in 2054ms
creator CPython3Posix(dest=/Users/unhuman_dev/.local/share/virtualenvs/capstone-project-YzbI2eRH, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/unhuman_dev/Library/Application Support/virtualenv)
added seed packages: pip==21.3.1, setuptools==60.3.1, wheel==0.37.1
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
✔ Successfully created virtual environment!
Virtualenv location: /Users/unhuman_dev/.local/share/virtualenvs/capstone-project-YzbI2eRH
I noticed that the pipenv in user2 use path /usr/local/bin/python3.9 for generating venv, so I go back to user1 and check if python3.9 is in /usr/local/bin/.

Then tried with that path but failed again.
unhumanWu-2:capstone-project unhumanWu$ pipenv --python /usr/local/bin/python3.9
Creating a virtualenv for this project...
Pipfile: /Users/Shared/Learning/Udacity/Udacity-de/capstone-project/Pipfile
Using /usr/local/bin/python3.9 (3.9.12) to create virtualenv...
⠴ Creating virtual environment...Using base prefix '/Library/Frameworks/Python.framework/Versions/3.9'
New python executable in /Users/unhumanWu/.local/share/virtualenvs/capstone-project-YzbI2eRH/bin/python3.9
Not overwriting existing python script /Users/unhumanWu/.local/share/virtualenvs/capstone-project-YzbI2eRH/bin/python (you must use /Users/unhumanWu/.local/share/virtualenvs/capstone-project-YzbI2eRH/bin/python3.9)
ERROR: The executable /Users/unhumanWu/.local/share/virtualenvs/capstone-project-YzbI2eRH/bin/python3.9 is not functioning
ERROR: It thinks sys.prefix is '/Library/Frameworks/Python.framework/Versions/3.9' (should be '/Users/unhumanWu/.local/share/virtualenvs/capstone-project-YzbI2eRH')
ERROR: virtualenv is not compatible with this system or executable
Running virtualenv with interpreter /usr/local/bin/python3.9
✘ Failed creating virtual environment
[pipenv.exceptions.VirtualenvCreationException]: /Users/unhumanWu/anaconda/lib/python3.6/site-packages/virtualenv.py:1039: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
Failed to create virtual environment.
Anything missing here?