0

I'm currently following this guide to install python and its libraries onto my Mac OS. http://www.nyx.net/~mlu/pages/computing/installing_and_configuring/installing_and_configuring_Python_on_Mac_OS_X/#.WCLNgeErJE4

In step 4, I brew installed python and python3 Upon checking the path of python and python3, I found that python was in /usr/bin/python while python3 is in /usr/local/bin/python3

How do I get my python to install in /usr/local/bin?

UPDATE Upon looking on my terminal, I can see that the brew install python had installed it in /usr/local/bin (version is 2.7.12) but somehow I am accessing a python that was installed in /usr/bin (version is 2.7.10). How do i fix this?

Ashley Tam
  • 51
  • 8
  • 1
    Do you know about the `PATH` variable, and setting it in your `.bashrc`? –  Nov 09 '16 at 07:42
  • This Q&As may help: http://stackoverflow.com/questions/10343834/how-to-modify-path-for-homebrew –  Nov 09 '16 at 07:45
  • Use a virtualenv with a specific path to the Python executable you want. – jonrsharpe Nov 09 '16 at 07:45
  • Alternatively, make an alias (mine are `py35` and `py27`), so you don't even have to modify your PATH. –  Nov 09 '16 at 07:45
  • @jonrsharpe virtualenv really isn't necessary: `/usr/local/` simply serves as one big virtualenv already, and then everything is in a logical place. –  Nov 09 '16 at 07:47
  • So my /usr/local/bin is ahead of /usr/bin - my path is /usr/local/heroku/bin:/Users/ashleytam/.rbenv/shims:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/9.3/bin so why is the python 2.7.10 version being accessed and not the 2.7.12 one? – Ashley Tam Nov 09 '16 at 07:54
  • @Evert the guide says to pip install virtualenv. If i have a usr/local should I still install the virtualenv? – Ashley Tam Nov 09 '16 at 07:58
  • In a new shell (there are sometimes caching issues), what is the output of `which python`, `which python2`, and `type python` and `type python2`? – languitar Nov 09 '16 at 09:13
  • The guide also suggest to use Anaconda. That doesn't make sense, since Anaconda brings its own Python distribution. –  Nov 09 '16 at 09:38
  • Unless you need *specific* versions of packages, and not just the current version, there is no need to use a virtualenv. Installing everything directly in `/usr/local/pythonx.y/site-packages` (which is where things automatically go when you use `pip` to install things) is fine. My suggestion is to use a `virtualenv` when you have very specific dependencies, or you need a stable environment for years to come that doesn't change (such as a server of sorts). –  Nov 09 '16 at 09:41
  • Practical tip when using `pip`: make sure to append the relevant (Python) version to the name; otherwise you could be installing packages for the wrong Python. E.g., use `pip2.7` or `pip3.5.` Even more explicitly, use the module variant, e.g. `python3.5 -m pip install blah`. –  Nov 09 '16 at 09:45
  • "So my /usr/local/bin is ahead of /usr/bin": I do often have to type `rehash` or start a new shell/terminal when I just installed something, so the shell can find it (depending on the shell). Have you tried that alread? –  Nov 09 '16 at 09:47

0 Answers0