Pipenv: When I upgrade Python version by homebrew, pipenv die.

Created on 8 Jul 2019  Â·  7Comments  Â·  Source: pypa/pipenv

Issue description

First of all, I have Python 3.6 in my mac, this Python was installed by homebrew.

I installed pipenv by this command:

python3 -m pip install pipenv

now, I upgrade Python3 to Python 3.7 by the following command:

brew upgrade python3
brew cleanup

Now, pipenv has dead.

when I run command pipenv, it will raise the error msg:

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

Expected result

Pipenv work.

Actual result

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

Most helpful comment

So wait, the first recommendation in the README is not the best way to install pipenv? That seems like a problem.

In any case, I solved this by doing brew install --force pipenv then brew link --overwrite pipenv to do a reinstall.

All 7 comments

It's not Pipenv to blame, it's the way how you install Pipenv.

In short, do not use Homebrew to install CLI apps(Docs recommend it which may be misleading for new users).

Homebrew with install Python to a standalone location and create softlinks under /usr/local/bin. When upgrading, the old python versions are removed, thus breaking the Pipenv which refers to the location of old python.

Close it for now.

In short, do not use Homebrew to install CLI apps(Docs recommend it which may be misleading for new users).

Misleading docs are a problem, one should atleast mention this in the README. Would you be willing to accept pull requests for it?

Hello.

What is the right way to install pipenv on macOS?

one way to resolve OP's original issue is manually symlink to the place where pipenv expects, find where your desired python version is installed with brew and then symlink it to /usr/local/opt/python:

ln -s /usr/local/opt/[email protected]/ /usr/local/opt/python/

I fixed this by manually updating my /usr/local/bin/pipenv file.

I met this problem after upgrading from 3.7 to 3.8.

I edited /usr/local/bin/pipenv file and changed
#!/usr/local/opt/python/bin/python3.7

to
#!/usr/local/opt/python/bin/python3.8

which seemed to fix the issue, for me

So wait, the first recommendation in the README is not the best way to install pipenv? That seems like a problem.

In any case, I solved this by doing brew install --force pipenv then brew link --overwrite pipenv to do a reinstall.

thanks for all reply

Was this page helpful?
0 / 5 - 0 ratings