zsh: /usr/local/bin/pipenv: bad interpreter: /usr/local/opt/python/bin/python3.7: no such file or directory
Solution 1
I had this same error with awscli
. The solution was to install [email protected] via homebrew and then cp
that installation into the directory awscli
expected.
brew install [email protected]
cp -r /usr/local/opt/[email protected]/bin/python3.7 /usr/local/opt/python/bin/python3.7
Solution 2
You don't need to uninstall anything. Simply change the interpreter at /usr/local/bin
and have your current python path in pyenv handy:
type python3
copy the path
vi /usr/local/bin/pipenv
It will look something like this:
Once it's changed, you will probably have to download pipenv again. Don't worry, your env is fine.
pip install pipenv
Go play in your env
Solution 3
Run in terminal:
brew install python3 && cp /usr/local/bin/python3 /usr/local/bin/python
Related videos on Youtube

Ryan Payne
Software engineer who enjoys playing bluegrass and country music.
Updated on June 08, 2022Comments
-
Ryan Payne 7 months
I recently switched from bash to zsh (MacOS). I haven't used pipenv since the switch. Now when I run any pipenv command I get the following error:
$ pipenv install zsh: /usr/local/bin/pipenv: bad interpreter: /usr/local/opt/python/bin/python3.7: no such file or directory
I use pyenv for Python dependency management:
$ which python /Users/ryan.payne/.pyenv/shims/python
My default python version is 3.7.3:
$ pyenv versions system 2.7.16 3.6.8 * 3.7.3 (set by /Users/ryan.payne/.pyenv/version)
It seems like pipenv is not using my pyenv version of Python. How do I get pipenv working again?
-
Charles Duffy over 2 years"Bad interpreter" means exactly what it says. Check the first line of the script that fails for the "shebang" -- the specification of what interpreter is to be used to run that script. Make sure that shebang points to an interpreter that actually exists.
-
Charles Duffy over 2 years...if you want it to traverse your PATH to find a copy of
python
to use (and thus, to use the same onewhich
finds), then you need it to start with#!/usr/bin/env python
; whereas right now it presumably starts with#!/usr/local/opt/python/bin/python3.7
, which the error message indicates doesn't exist or is missing runtime dependencies..
-
-
A D about 1 yearI had the same problem with
black
on mac afterbrew upgrade
. The similar procedure worked for me. Thnx -
Tomas.R 9 monthsI had python3 already installed so I just ran this command and it worked : cp /usr/local/bin/python3 /usr/local/bin/python