title: Mac psql/readline - Library not loaded
body: <p>I'm working on a Mac, Sierra 10.12.3, and I'm trying to access a PostgreSQL database via the <code>psql</code> command, but it threw the error </p>
  
  <pre><code>dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib
  Referenced from: /usr/local/bin/psql
  Reason: image not found
  Abort trap: 6
  </code></pre>
  
  <p>A day or two ago, I was working with someone and I needed to install pip, so I ran <code>brew install pip</code>, and it was all good. This is the first time I'm trying to run <code>psql</code> since then and I'm not certain that this has anything to do with my problem, but it seems likely since I haven't made any other changes.</p>
  
  <p>Now I did a little detective work and found that if I went to <code>/usr/local/opt/</code> there was indeed a <code>readline</code> alias directory that pointed to <code>/usr/local/Cellar/readline/7.0.1</code> (version 7.0.1 also seeming to have gotten installed at some point - maybe as part of pip? Maybe I did it by mistake...) so it made some sense that the original error should be thrown. I changed the alias to point to <code>/usr/local/Cellar/readline/6.3.8</code> and the error changed slightly:</p>
  
  <pre><code>dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib
  Referenced from: /usr/local/bin/psql
  Reason: no suitable image found.  Did find:
  /usr/local/opt/readline/lib/libreadline.6.dylib: stat() failed with errno=20
  Abort trap: 6
  </code></pre>
  
  <p>So it seems like I'm getting <em>somewhere</em>, but still having an issue. If anyone can shed some light on a solution, I would be forever grateful.</p>