2

Previously I had the default Python 2.7, and I have a lot of virtualenvs created under python 2, using virtualenvwrapper. Recently, I wanted to be able to use python 3 as well as python 2.

brew install python3 no longer works, so after some research, I ran brew upgrade python followed by brew install python2 to get back Python 2. However, I discovered that the python 3 installation process changed the default "python" to python 3, and that this broke all of my virtualenvs.

For example, if I execute workon test in the console, I get the errors

/usr/local/opt/python/bin/python3.6: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper') /usr/local/opt/python/bin/python3.6: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper') /usr/local/opt/python/bin/python3.6: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper') /usr/local/opt/python/bin/python3.6: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')

How can I unscrew-up my system? I need to be able to get back all my old work, even if it means obliterating python 3, although the ideal solution would be to find a way to have python 3 installed along side without interfering with the existing python 2 setup.

1 Answer 1

4

I eventually solved the issue by running

brew switch python 2.7.14
brew link --overwrite python

I'm not sure if that was the correct solution, but at least it seems to be working now.

2
  • confirmed. i didn't even need brew link; brew switch alone fixed it for me.
    – ryan
    Commented Jul 3, 2018 at 0:03
  • That gives me an error: /usr/local/Homebrew/Library/Homebrew/global.rb:12:in require': cannot load such file -- active_support/core_ext/object/blank (LoadError) from /usr/local/Homebrew/Library/Homebrew/global.rb:12:in <top (required)>' from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in require_relative' from /usr/local/Homebrew/Library/Homebrew/brew.rb:23:in <main>' Commented Jun 5, 2019 at 20:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .