Osx Install Python

/ Comments off

Python for Mac OS X. Python comes pre-installed on Mac OS X so it is easy to start using. However, to take advantage of the latest versions of Python, you will need to download and install newer versions alongside the system ones. The easiest way to do that is to install one of the binary installers for OS X from the Python Download page. Install the Latest Python Versions on Mac OSX¶ 2017-10-12 Discuss Once you have decided that Python is an awesome language to learn and you have heard all about the the cool features awaiting you, you are determined to install the latest versions on your laptop so that you can start developing.


Once you have decided that Python is an awesome language to learnand you have heard all about the the cool featuresawaiting you, you are determined to install the latest versions on your laptop so that you can startdeveloping.

Install python on osx

Osx Install Python 3.9

  • What’s New In Python 3.6 - December 23, 2016
  • What’s New In Python 3.5 - September 13, 2015
  • What’s New In Python 3.4 - March 16, 2014
  • What’s New In Python 3.3 - September 29, 2012
  • What’s New In Python 3.2 - February 20, 2011
  • What’s New In Python 3.1 - June 27, 2009
  • What’s New In Python 3.0 - December 3, 2008
  • What’s New In Python 2.7 - July 3, 2010
  • What’s New In Python 2.6 - October 1, 2008

Download Mac OS X 64-bit/32-bit installer; Python 2.7.7rc1 - May 17, 2014. Download Mac OS X 32-bit i386/PPC installer; Download Mac OS X 64-bit/32-bit installer; Python 3.4.1rc1 - May 5, 2014. Download Mac OS X 32-bit i386/PPC installer; Download Mac OS X 64-bit/32-bit installer; Python 3.4.0rc3 - March 10, 2014. Download Mac OS X 32-bit i386. Whether you install the updated Python 3 with the package installer or Homebrew, the default version of Python 2.7 that comes preinstalled with Mac OS and Mac OS X will still be installed, completely untouched, and can be run with the simple “python” command as always. Until Apple decides to set Python 3.x, as the default you're going to have to install it yourself. A Single Command to Run Python 3. For some of you reading this, this command may be enough. You can run Python 3 using this command (with the 3 at the end). If that's all you came for, no worries. Have a fun day and happy coding.

You may be a little concerned about the differences between Python 2 and Python 3, so you wantto make sure that you have the latest versions of each available. This will enable you to switchbetween them easily and work on porting Python 2 programs to Python 3.

Osx Install Python

OS vendor Python versions lag behind the latest available and can only be updated by installing amajor patch or bolting-on an additional Python installation:

OS Version System Python Version
OSX 10.13 2.7.10
OSX 10.12 2.7.10
OSX 10.11 2.7.10
Ubuntu 16.04 LTS Xenial Xerus 2.7.11
Ubuntu 14.04 LTS Trusty Tahr 2.7.5
Ubuntu 12.04 LTS Precise Pangolin 2.7.3

One way to work around this issue is to use pyenv to install theversions of Python you want to use. This tool provides a simplified build environment for installingthe Pythons you want, while providing a set of shell script shims that makes it easy to switch betweenthem. This tool was inspired by and forked from rbenv andruby-build.

Install Python with pyenv¶

Python
  1. Start a Terminal session.

  2. Install Homebrew and Xcode Command Line Tools.

  3. Install pyenv.

  4. If you already have pyenv installed, you can upgrade it to gain access to the latest Pythonversions. The pyenv tool is updated periodically with new formulas for the latest releases.

  5. Add configuration to your .bash_profile to initialize pyenv every time you start a newTerminal. The PYENV_ROOT, which is where Python versions and packages will be installed,defaults to $HOME/.pyenv.

  6. Load your .bash_profile configuration changes.

  7. List the available Python versions. Notice that you have access to several differentdistributions: python.org (plain version numbers), anaconda, ironpython, jython, miniconda,pypy and stackless. We will install the standard Python versions released bypython.org, otherwise known as CPython, because theinterpreter is written in C.

  8. If you are running OSX 10.13, you will need to set the following environment variables, when youinstall new Python versions. See #988 for more details.

  9. Install Python versions.

  10. List the available Python versions.

  11. Activate a Python version and verify that it is available.

  12. Activate another Python version and verify that it is available.

  13. If desired, activate multiple Python versions and verify that they are available.PEP 394 -- The 'python' Command on Unix-Like Systemsexplains conventions for naming python binaries.

  14. Create new directories for Python projects, add pyenv local version files and verify the Pythonversions. Your python version will automatically switch when you change into these directories.

Useful Python Packages¶

This is a small collecton of useful packages that will help get you started doing useful thingswith Python.

Install flake8, which is a static analyzer that enforcesgood Python coding style and alerts you to coding mistakes. Now that you have Python installed,you can use the pip command to install any additional modules that you want to use. You willneed to install modules separately for each version of Python you are actively using.

Install advanced Python Read-Eval-Print-Loop (REPL) packages, which will make it easier to explorePython code, because they grant access to tab completion and fancy editing capabilities. The ipythontool is a command line REPL, which can be exited with ctrl-d. Jupyter Notebook is a browser-basedREPL that operates on individual cells of code. The IPython Interactive Computingwebsite has more information on these tools.

Install Requests: HTTP for Humans, which makes it easyto consume HTTP services. See GitHub's REST API v3 documentationfor more details on endpoints that are avaialble.

Install Flask: A Python Microframework, which can be used to quickly buildsmall websites that automate everyday tasks.

If you need Python package isolation on a per-project basis, because you have conflicting setsof packages specified for different projects, you can use virtualenvto set up separate environments. The virtualenv tool establishes a clean room Python installation,either based upon the current version of Python in use, or a version specified on the command line.If you have multiple Python versions activated in pyenv, you can use virtualenv to switch betweenthem easily.

Automated Testing with Python¶

While working on Python programs, you may be interested in automating testing. The most commonchoice for implementing this is tox, which willallow you to run tests with multiple different versions of Python, if needed.

Python Packaging¶

Osx

After completing a Python program or two, you will be interested in learning how to distribute themeffectively. The Python Packaging User Guide has some good adviceon this topic.

Quickstart Commands¶

Python for Mac OS X

Python comes pre-installed on Mac OS X so it is easy to startusing. However, to take advantage of the latest versions ofPython, you will need to download and install newer versionsalongside the system ones. The easiest way to do that is toinstall one of the binary installers for OS X from thePython Download page. Installers areavailable for the latest Python 3 and Python 2 releases thatwill work on all Macs that run Mac OS X 10.5 and later.

Python releases include IDLE, Python's built-in interactivedevelopment environment. If you download and install Pythonfrom the release page, you may also need to download and installa newer version of Tcl/Tk for OS X. See theIDLE and Tkinter on OS X page formore information.

Osx install python modules

You can run a Python interpreter by double-clicking onApplications / Utilities / Terminal and typing python3 (if you'veinstalled a version of Python 3) or python (to use Python 2) inthe window that opens up. You can also launch IDLE for the Pythonversion you have installed by double-clicking its icon inthe appropriate Python version folder in the Applications folderor you can also just type idle3 or idle in a terminal window.

There are many thousands of additional Python software packagesavailable through PyPI, the PythonPackage Index. We recommend you use thepip tool to simplifyinstalling and managing additional packages. pip is includedwith Python 3.4 releases; for earlier releases, follow the pipinstall instructions.

Among the packages available through PyPI are some that arespecifically for OS X environments. Among these are:

Osx Install Python

  • pyobjc which providesa bridge between Python and Objective-C, allowing you to writefull-featured native Cocoa applications in pure Python.
  • py2app which allowsyou to make standalone OS X double-clickable application bundlesand plugins from Python scripts.

For more information about Python on OS X, see the mailing list and archivesfor thePython-Macintosh Special Interest Group.

Alternative Packages for Mac OS X.

  • ActiveState ActivePython(commercial and community versions, including scientific computing modules).
  • Enthought Python DistributionThe Enthought Python Distribution provides scientists with a comprehensive setof tools to perform rigorous data analysis and visualization.

Osx Install Python Pip

Python and a comprehensive set of third-party packages and libraries are alsoavailable from several open source package manager projects for OS X,including: