0

I'm trying to follow this guide to set up Virtual Environments on OSX 10.8.5 (Lion). Homebrew is successfully installed, and the following updates completed successfully:

$ pip install --upgrade distribute  
$ pip install --upgrade pip 

However, which python still shows /Library/Frameworks/Python.framework/Versions/2.7/bin/python. Why?? (I expected /usr/local/bin/python instead, and the goal is to use venv(s) to separate projects.)

Updates...
$PATH information:

host:~ username$ echo $PATH
 /Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/
 Frameworks/Python.framework/Versions/3.4/bin:/usr/bin:/bin:/usr/
 sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin 
host:~ username$  

Turns out ... host:~ user$ brew install python Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). No changes to formulae.

Warning: python-2.7.13 already installed, it's just not linked.

Running doctor showed a number of problems, but the solution would be... host:~ user$ brew link python

This ultimately required a force (--overwrite) ...

For references: brew install python, but then: "python-2.7.6 already installed, it's just not linked" python homebrew by default

However I don't understand why this happened. If someone can explain what happened (why homebrew didn't update the link), I'm happy to award an answer.

Community
  • 1
  • 1
user3.1415927
  • 367
  • 3
  • 19

1 Answers1

0

If your PATH in OS X doesn’t point to /usr/local/bin first, you have to set up your virtualenv using the -p option, which allows you to specify the path to the python interpreter that you want to use within the virtualenv:

cd /path/to/project
virtualenv . -p /usr/local/bin/python
. bin/activate
python --version
2ps
  • 15,099
  • 2
  • 27
  • 47
  • Hmmm, it looked like $PATH would be updated after `brew install python` (line 323 in the tutorial).. – user3.1415927 Feb 07 '17 at 00:38
  • I can’t speak to the validity of any particular tutorial. I can tell you that the `-p` option is what you should use to specify your python interpreter of choice. – 2ps Feb 07 '17 at 01:21