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?
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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.