I would like to have a local install of python in my mac for an older version of python. For instance I have python 2.7.10. However I would like python 2.7.6 for a particular project development. How can I install 2.7.6, without impacting mac's default python or previously installed versions?
-
Related: http://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv – OneCricketeer Apr 06 '16 at 12:21
-
There shouldn't be any significant difference between 2.7.6 and 2.7.10, apart from bug fixes. Why do you need those two versions? – Daniel Roseman Apr 06 '16 at 12:25
2 Answers
You can use Homebrew or [MacPorts] to install multiple versions of Python on the same machine without necesarrily overriding the default Python interpreter (https://www.macports.org/) (based on my personal experience I recommend Homebrew).
Have a look at http://docs.python-guide.org/en/latest/starting/install/osx/#doing-it-right.
Edit: I checked for Python and it's not among the standard old repositories like homebrew/versions
or homebrew/boneyard
so you have to install it directly from github by searching for the formualr with 2.7.6
version which is this one:
Brew can install it right from github:
$ brew install https://raw.githubusercontent.com/Homebrew/legacy-homebrew/72eb84e61e46f9c22193b7b0fbcf60993b795c8e/Library/Formula/python.rb

- 93,354
- 25
- 191
- 226
-
How do I specify a particular version - 2.7.6 using brew? Furthermore I would like this install not to impact already installed versions of python – tsar2512 Apr 06 '16 at 12:19
-
I updated my answer. If you already have `python` installed via `brew` you'd just have to unlink it with `brew unlink python` which only removes symlinks but keeps all binaries (eg. on my system in /usr/local/Cellar/python/2.7.10_2/bin/python). You can also install python with `brew`, right after that unlink it and call it only via its full path. – martin Apr 06 '16 at 12:42
You should learn about using virtualenvs. A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.
Here You have a good tutorial for Mac OS, it's written for Yosemite but should work on other os versions too.
As mentioned in this question: Use different Python version with virtualenv, You can use virtualenv -p /usr/bin/python2.6 <path/to/new/virtualenv/>
command to specify the Python version for virtualenv.

- 1
- 1

- 3,355
- 4
- 32
- 44