7

I have to use Python 3.6.5 because of a library I use that keeps showing bugs on 3.7.0 (TensorFlow).

I installed Python 3.6.5 using Homebrew as follows:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb

If I install vim using Homebrew:

brew install vim --with-python

it updates Python to 3.7.0. So I end up having a working vim but broken TensorFlow code. What I did was switching back to 3.6.5 after installing vim:

brew switch python 3.6.5_1

And I ended up having a working TensorFlow code but a broken vim:

dyld: Library not loaded: /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/Python
  Referenced from: /usr/local/bin/vim
  Reason: image not found
[1]    83442 abort      vim
1
  • 4
    This sounds like a situation begging for a virtual environment. There are a few options for python, but my favorite is pyenv. I'd recommend letting Homebrew manage the 3.7.0 installation and vim, and use pyenv to manage your development environment with TensorFlow. Commented Oct 9, 2018 at 21:33

4 Answers 4

4

To solve this with homebrew, you can temporarily backdate homebrew-core and set the HOMEBREW_NO_AUTO_UPDATE variable to hold it in place:

cd `brew --repo homebrew/core`
git checkout f2a764ef944b1080be64bd88dca9a1d80130c558
export HOMEBREW_NO_AUTO_UPDATE=1
brew install python
brew install vim --with-python

I don't recommend permanently backdating homebrew-core, as you will miss out on security patches, but it is useful for testing purposes.

A more robust approach, would be to use pyenv as suggested in the comment by @Dustin Wheeler. You can also extract old versions of homebrew formulae into your own tap (tap_owner/tap_name) using the brew extract command:

brew extract python tap_owner/tap_name --version=3.6.5
1
  • pyenv worked perfectly and it has a bunch of other lovable features. Commented Oct 10, 2018 at 7:50
4

Another way, if you also have python 3.7 in your system.
Go to the dir, where vim trying to find the python.

cd /usr/local/opt/python/Frameworks/Python.framework/Versions

And create a link to 3.7 python. Example for brew installed python:

ln -s /usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/ 3.7
0
2

Error message:

✗ vim test
dyld: Library not loaded: /usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/Python
  Referenced from: /usr/local/bin/vim
  Reason: image not found
[1]    72498 abort      vim test

This upgrade solved my problem:

brew upgrade vim

2
  • 1
    This worked for me as well.
    – Anuja
    Commented Dec 1, 2020 at 15:10
  • 1
    This worked for me and should probably be the approved answer. Commented May 19, 2021 at 4:48
0

For python versioning you shopuld use virtual environments. In these each project can have a different version of python and libraries.

These allow vim to use one version of Python and your Tensorflow project another

There are two of these.

  1. conda

  2. Python's inbuilt one venv recommended since python 3.5

You must log in to answer this question.

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