zsh: /usr/local/bin/pipenv: bad interpreter: /usr/local/opt/python/bin/python3.7: no such file or directory

Ryan Payne picture Ryan Payne · Aug 20, 2020 · Viewed 10.1k times · Source

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?

Answer

Matthew Hinea picture Matthew Hinea · Oct 19, 2020

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