1

I used brew to install python 2.7 and now my mac have 2 python version

on in /usr/bin/python and another on in /usr/local/Cellar/python/2.7.12_2/

pip installed oursql to /usr/local/lib/python2.7/site-packages

what should i do about it?

Desmond
  • 5,001
  • 14
  • 56
  • 115

2 Answers2

1

A good solution can be found here. However, I am gonna explain the nature of the issue and a more quick solution here too:

Problems of this kind, that is when you have installed some package, but Python is not able to find it usuallly is because of one of the following reasons:

  • You have installed it for a different version of Python
  • You have installed it for a different user (wiht sudo, for example)
  • You have installed it in a local or non-standard package directory

Here you are are facing the third type. A quick solution without doing any changes to search path of the system is to simply add the path to the directory that the library is installed at to your Python search path:

import sys, os
sys.path.append(os.path.abspath(<path to the installation directory>))

in your case:

sys.path.append(os.path.abspath('/usr/local/lib/python2.7/site-packages'))
Community
  • 1
  • 1
Ali
  • 1,605
  • 1
  • 13
  • 19
0

Finally got it work after I symlink with brew's python

It was not symlinked into /usr/local

The command is simply brew link python and now which python will point to /usr/local/bin/python

Desmond
  • 5,001
  • 14
  • 56
  • 115