Osx Python Update
Doing it Right¶. Let’s install a real version of Python. Before installing Python, you’ll need to install a C compiler. The fastest way is to install the Xcode Command Line Tools by running xcode-select-install. Python 3 (released in 2008) is the newest version of Python, and most features have not changed. Most packages have been updated to Python 3 by now (2016). So, if your lab does not have a preference, I recommend using Python 3. There are a couple key differences for novice programmers: In Python 2, you can print with print 42 or print(42). Using python 2.7.10 on osx I had to import ElementTree as from xml.etree.ElementTree import ElementTree – Ben Page Jan 11 '16 at 14:34 because it is a C wrapper you might find difficulty deploying it to AWS Lambda unless you compile on an EC2 instance or a Docker image of AWS Linux – CpILL Jul 12 '18 at 13:51.
- Mac Python Update
- Mac Update Python Path
- Macos Python Update
- Mac Python Update Pip
- Mac Python Update Terminal
- Set up your computer
- Practice
Start here!
Try this 10-minute tutorial. When itloads, type tutorial
and press Enter to start.
Set up your computer
This is our recommended way to install Python on your system.
Install Anaconda
- Please download the Anaconda installer. We recommend Python 3.
- Choose
Install for me only
- By default, Anaconda will prepend itself to your PATH – leave this as is
- When Anaconda has finished installing, open a terminal (Linux, OSX), or the Anaconda Prompt (Windows)
- Type
conda update conda
, hit enter, and then type 'y' (and hit enter) - Type
conda update anaconda
, hit enter, and then type 'y' (and hit enter)
Run the Jupyter Notebook
With Jupyter, you intersperse code, output, explanatory text, and figures in one big file called a 'notebook.' Notebooks are a convenient format to explore a language and to share examples of code.
- To run a notebook, open the Terminal (Linux, OSX) or Anaconda Prompt (Windows) and type
jupyter notebook
. - The notebook will open a new tab in your default browser. Do not close the terminal, as this will also shutdown the notebook.
- When it has loaded, click on 'New' (at the top right) and then 'Python3' to create a new notebook.
Mac Python Update
Python 2 vs Python 3
Python 3 (released in 2008) is the newest version of Python, and most featureshave not changed. Most packages have been updated to Python 3 by now (2016).So, if your lab does not have a preference, I recommend using Python 3.
There are a couple key differences for novice programmers:
Mac Update Python Path
- In Python 2, you can print with
print 42
orprint(42)
. In Python3, you need to use parentheses, as inprint(42)
. In Python 2, division of two integers like
5/2
will evaluate to2
. (Python will drop the remainder if both numbers are integers.)Python 3 does exact division ('2.5', in this example). If you use Python 2 and do not want this behavior, add this line at the top of each program:from __future__ import division
.
Text editors and IDEs
For creating large projects in Python, we recommend using a text editor in combination with the Jupyter notebook. Popular choices include:
For even larger projects, a well-engineered IDE (Interactive Development Environment) may be better than a text editor. Typically, IDEs include drag-and-drop support for debugging and refactoring. Popular choices include:
Practice
Past topics of the Python Working Group are linked here. Suggestions? Send us an email at dlab-frontdesk@berkeley.edu.
Macos Python Update
Software Carpentry
These exercises are really useful to get acquainted with Python. Here's a link to the Jupyter notebook version and the webpage version.
Python for Social Sciences
This is a free online book by Jean Mark Gawron. It's free and online at this link.
Mac Python Update Pip
Resources
Mac Python Update Terminal
Check the Learning Resources page for more learning materials. Others in the community may also have relevant materials.