pipenv: Homebrew installation broken on Python < 3.7
This is probably related to #2296, but I’m currently unable to upgrade pipenv past 2018.6.25
using Homebrew.
I have my Python pinned at 3.6.5
with brew switch python 3.6.5_1 && brew pin python
Because of this I have to --build-from-source
for any upgrade to a brew-installed package that depends on python
as the bottles are built on Python 3.7.
After brew upgrade pipenv --build-from-source
I get the following error:
pipenv --help
Traceback (most recent call last):
File "/usr/local/Cellar/pipenv/2018.10.9/libexec/bin/pipenv", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.6/site-packages/pkg_resources/__init__.py", line 26, in <module>
import zipfile
ModuleNotFoundError: No module named 'zipfile'
Switching back to 2018.6.25
resolves the issue, but it’d be nice to get on the latest version.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 16 (4 by maintainers)
Thanks @amancevice 😃 I finally managed to make it work with pipenv. For documentation here are the steps:
brew uninstall pipenv
brew install pipenv
brew install python 3.6.4_4
ln -s /usr/local/Cellar/python/3.6.4_4/bin/python3 /usr/local/opt/python/bin/python3.6
because pipenv will ttry to find it here…pipenv shell --python /usr/local/Cellar/python/3.6.4_4/bin/python3
a new virtualenv will be createdpipenv shell
orpipenv install
with the python 3.6 version@amancevice In my case I did not have to use pyenv. The only annoying thing is that you need to find where brew will install python distribution.
Closing since there isn’t really anything to track in this repo. Feel free to reopen (or raise a new issue) if cooperation from us is needed to resolve this issue.
I don’t believe any of the maintainers contribute to the Homebrew formula. We try to fix things when they are broken, but none of us have much more stake in the formula than, say, you do.
I do have some personal experience with Homebrew, and your walkthrough does help explain things a lot. Thanks! Based on the above information, I feel your patch to the post-install hook makes sense. It makes things better in certain situations (i.e. yours), and does not break existing situations. Unfortunately, we don’t really have a say on this topic; you’ll need to convince the Homebrew maintainers to get it in 😦
OK, I’ve isolated the problem to this line in
post_install
:If I understand correctly, this line is replacing text in the file
lib_python_path/"orig-prefix.txt"
; specifically its replacing the value ofFormula["python"].opt_prefix
with the value ofFormula["python"].prefix.realpath
.The problem is that
Formula["python"].prefix.realpath
points to3.7.0
(or whatever the current version of thepython
formula is) and not my linked3.6.5
.@ebb-earl-co if you’re luck it’ll be as simple as:
Typing
brew switch pipenv
by itself will show you all the versions you have installed. These get cleaned up onbrew cleanup
so if you run a tight ship it’s probably long gone.If it’s gone you’ll have to rewind your Homebrew tap to when it was the latest version. You can do this using the same logic as above for Python, but you’ll need to find the correct checksum by grepping the logs. I’ll walk you through it:
Be sure to pin your pipenv to prevent unwanted upgrades with
brew pin pipenv
.